Skip to content

Commit

Permalink
dev-infra: add jest html reporting, assert at the end so cleanup runs…
Browse files Browse the repository at this point in the history
…, add razzle_meta
  • Loading branch information
fivethreeo committed Feb 10, 2021
1 parent 99139c5 commit b01531e
Show file tree
Hide file tree
Showing 5 changed files with 234 additions and 15 deletions.
3 changes: 3 additions & 0 deletions examples/with-custom-environment-variables/package.json
Expand Up @@ -20,5 +20,8 @@
"webpack": "^4.44.1",
"babel-preset-razzle": "4.0.0-canary.46",
"webpack-dev-server": "^3.11.2"
},
"razzle_meta": {
"port": "4000"
}
}
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -21,6 +21,7 @@
"got": "^11.0.2",
"husky": "^4.2.3",
"jest": "^26.6.3",
"jest-html-reporter": "^3.3.0",
"leaked-handles": "^5.2.0",
"lerna": "^3.20.2",
"lerna-changelog": "^1.0.1",
Expand Down
11 changes: 5 additions & 6 deletions test/examples/isomorphic-examples.test.js
Expand Up @@ -173,6 +173,7 @@ beforeAll(async function(done) {

afterAll(async function(done) {
await browser.close();
await new Promise((r) => setTimeout(r, 3000));
done();
});

Expand Down Expand Up @@ -274,20 +275,18 @@ describe(`tests for isomorphic examples`, () => {
}
}, 15000)
subprocess.stdout.on('data', waitForData);
await subprocess;
})
assert.ok(resolved, `yarn start for ${example} failed`);

if (resolved) {
await new Promise((r) => setTimeout(r, 5000));
await page.goto('http://localhost:3000/');
await page.goto(`http://localhost:${razzleMeta.port||'3000'}/`);
await page.screenshot({ path: path.join(testArtifactsDir, `${example}.png`) });
await new Promise((r) => setTimeout(r, 2000));
}

await new Promise((r) => setTimeout(r, 2000));

terminate(subprocess.pid, 'SIGINT', { timeout: 3000 }, () => {
terminate(subprocess.pid, 'SIGINT', { timeout: 3000 }, async () => {
terminate(subprocess.pid);
assert.ok(resolved, `yarn start for ${example} failed`);
done();
});

Expand Down
12 changes: 9 additions & 3 deletions test/jest.examples.config.json
Expand Up @@ -2,6 +2,12 @@
"roots": ["<rootDir>/examples"],
"collectCoverageFrom": ["**/*.js"],
"testMatch": [
"<rootDir>/examples/**/*(*.)@(spec|test).(ts|js)?(x)"
]
}
"<rootDir>/examples/**/*(*.)@(spec|test).(ts|js)?(x)"
],
"reporters": [
"default",
["jest-html-reporter", {
"pageTitle": "Examples Test Report"
}]
]
}

0 comments on commit b01531e

Please sign in to comment.