Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests for bundlers #2649

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 73 additions & 0 deletions integrationTests/bundlers/bundlers-test.js
@@ -0,0 +1,73 @@
const path = require('path');
const { execSync } = require('child_process');

const express = require('express');
const playwright = require('playwright');
const { expect } = require('chai');

const BUNDLERS = ['webpack'];
const BUILDS = ['prod', 'dev'];
const BROWSERS = ['chromium', 'firefox', 'webkit'];
const PORT = 4000;

describe('bundlers', function () {
const browsers = {};
let server;

this.timeout(60000);

before(async () => {
await Promise.all(
BROWSERS.map(async (browserName) => {
browsers[browserName] = await playwright[browserName].launch();
}),
);

const app = express();

app.use(express.static(__dirname));

return new Promise((resolve) => {
server = app.listen(PORT, resolve);
});
});

after(async () => {
await Promise.all(
BROWSERS.map(async (browserName) => {
await browsers[browserName].close();
}),
);

return new Promise((resolve) => {
server.close(resolve);
});
});

BUNDLERS.forEach((bundler) => {
describe(bundler, () => {
BUILDS.forEach((build) => {
describe(build, () => {
before(() => {
execSync('npm run build', {
cwd: path.join(__dirname, bundler, build),
});
});

BROWSERS.forEach((browserName) => {
it(`works in ${browserName}`, async () => {
const context = await browsers[browserName].newContext();
const page = await context.newPage();
await page.goto(
`http://localhost:${PORT}/${bundler}/${build}/index.html`,
);
const mainDiv = await page.$('#main');
const text = await mainDiv.innerText();
expect(text).to.equal('Hello Dolly');
});
});
});
});
});
});
});