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

Build: Use new test runner with builtin junit #19028

Merged
merged 3 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 99 additions & 4 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,29 @@ __metadata:
languageName: node
linkType: hard

"@babel/core@npm:^7.17.10":
version: 7.18.13
resolution: "@babel/core@npm:7.18.13"
dependencies:
"@ampproject/remapping": ^2.1.0
"@babel/code-frame": ^7.18.6
"@babel/generator": ^7.18.13
"@babel/helper-compilation-targets": ^7.18.9
"@babel/helper-module-transforms": ^7.18.9
"@babel/helpers": ^7.18.9
"@babel/parser": ^7.18.13
"@babel/template": ^7.18.10
"@babel/traverse": ^7.18.13
"@babel/types": ^7.18.13
convert-source-map: ^1.7.0
debug: ^4.1.0
gensync: ^1.0.0-beta.2
json5: ^2.2.1
semver: ^6.3.0
checksum: 4a880723a1ee5b878482ce2f359d690f09ed407667f3d19c97790b772b11bec3dd71f66b5fb76d2da41e0f80f06ac85dfce1b46696307fc124f192a08b85c3b8
languageName: node
linkType: hard

"@babel/core@npm:^7.18.10":
version: 7.18.10
resolution: "@babel/core@npm:7.18.10"
Expand Down Expand Up @@ -586,6 +609,17 @@ __metadata:
languageName: node
linkType: hard

"@babel/generator@npm:^7.18.13":
version: 7.18.13
resolution: "@babel/generator@npm:7.18.13"
dependencies:
"@babel/types": ^7.18.13
"@jridgewell/gen-mapping": ^0.3.2
jsesc: ^2.5.1
checksum: 801f8b68c951da7badc81b9ed773599fa30c969cee4c7b8698aed6ed02be9231a2dea5ffe2e5cc3d1471d3b0e554cd0b949409ae8a6567e80da22b0672e4e861
languageName: node
linkType: hard

"@babel/helper-annotate-as-pure@npm:7.16.7":
version: 7.16.7
resolution: "@babel/helper-annotate-as-pure@npm:7.16.7"
Expand Down Expand Up @@ -912,6 +946,15 @@ __metadata:
languageName: node
linkType: hard

"@babel/parser@npm:^7.18.13":
version: 7.18.13
resolution: "@babel/parser@npm:7.18.13"
bin:
parser: ./bin/babel-parser.js
checksum: c81e3c47b827a3dcbe7793a56834de1bb8769f303fef008b1e91a58545594e26d0ecf1a0ba859ae853f80421d5aca830e4b7262e9f146b7023c2210ee6312f8b
languageName: node
linkType: hard

"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:^7.16.7, @babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:^7.18.6":
version: 7.18.6
resolution: "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:7.18.6"
Expand Down Expand Up @@ -1767,7 +1810,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-transform-react-jsx-development@npm:^7.18.6":
"@babel/plugin-transform-react-jsx-development@npm:^7.16.7, @babel/plugin-transform-react-jsx-development@npm:^7.18.6":
version: 7.18.6
resolution: "@babel/plugin-transform-react-jsx-development@npm:7.18.6"
dependencies:
Expand All @@ -1778,7 +1821,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-transform-react-jsx-self@npm:^7.18.6":
"@babel/plugin-transform-react-jsx-self@npm:^7.16.7, @babel/plugin-transform-react-jsx-self@npm:^7.18.6":
version: 7.18.6
resolution: "@babel/plugin-transform-react-jsx-self@npm:7.18.6"
dependencies:
Expand All @@ -1789,7 +1832,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-transform-react-jsx-source@npm:^7.18.6":
"@babel/plugin-transform-react-jsx-source@npm:^7.16.7, @babel/plugin-transform-react-jsx-source@npm:^7.18.6":
version: 7.18.6
resolution: "@babel/plugin-transform-react-jsx-source@npm:7.18.6"
dependencies:
Expand All @@ -1815,7 +1858,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/plugin-transform-react-jsx@npm:^7.18.10":
"@babel/plugin-transform-react-jsx@npm:^7.17.3, @babel/plugin-transform-react-jsx@npm:^7.18.10":
version: 7.18.10
resolution: "@babel/plugin-transform-react-jsx@npm:7.18.10"
dependencies:
Expand Down Expand Up @@ -2387,6 +2430,24 @@ __metadata:
languageName: node
linkType: hard

"@babel/traverse@npm:^7.18.13":
version: 7.18.13
resolution: "@babel/traverse@npm:7.18.13"
dependencies:
"@babel/code-frame": ^7.18.6
"@babel/generator": ^7.18.13
"@babel/helper-environment-visitor": ^7.18.9
"@babel/helper-function-name": ^7.18.9
"@babel/helper-hoist-variables": ^7.18.6
"@babel/helper-split-export-declaration": ^7.18.6
"@babel/parser": ^7.18.13
"@babel/types": ^7.18.13
debug: ^4.1.0
globals: ^11.1.0
checksum: dd17b1c610da1480f78bb159789acd7e621313eeb49b39b42ea2adeadcd23d22d548890af1a87ad618bfdf9df4132239d6bc1b1b5b24448a6c230af9b6752830
languageName: node
linkType: hard

"@babel/types@npm:^7.0.0, @babel/types@npm:^7.11.5, @babel/types@npm:^7.12.11, @babel/types@npm:^7.12.6, @babel/types@npm:^7.12.7, @babel/types@npm:^7.13.12, @babel/types@npm:^7.16.7, @babel/types@npm:^7.16.8, @babel/types@npm:^7.18.6, @babel/types@npm:^7.18.9, @babel/types@npm:^7.2.0, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.4.0, @babel/types@npm:^7.4.4, @babel/types@npm:^7.6.1, @babel/types@npm:^7.7.0, @babel/types@npm:^7.7.2, @babel/types@npm:^7.8.3, @babel/types@npm:^7.8.6, @babel/types@npm:^7.8.7, @babel/types@npm:^7.9.6":
version: 7.18.9
resolution: "@babel/types@npm:7.18.9"
Expand All @@ -2408,6 +2469,17 @@ __metadata:
languageName: node
linkType: hard

"@babel/types@npm:^7.18.13":
version: 7.18.13
resolution: "@babel/types@npm:7.18.13"
dependencies:
"@babel/helper-string-parser": ^7.18.10
"@babel/helper-validator-identifier": ^7.18.6
to-fast-properties: ^2.0.0
checksum: 057c7f336c708f33c1a058695565ba6d311cabbd120ac514cf73fdd66cfc2c27693ff52a27e2c58f5a7741236fdcde67df524699be907d4e9edd1576d3d7058b
languageName: node
linkType: hard

"@base2/pretty-print-object@npm:1.0.1":
version: 1.0.1
resolution: "@base2/pretty-print-object@npm:1.0.1"
Expand Down Expand Up @@ -11755,6 +11827,22 @@ __metadata:
languageName: node
linkType: hard

"@vitejs/plugin-react@npm:^1.0.8":
version: 1.3.2
resolution: "@vitejs/plugin-react@npm:1.3.2"
dependencies:
"@babel/core": ^7.17.10
"@babel/plugin-transform-react-jsx": ^7.17.3
"@babel/plugin-transform-react-jsx-development": ^7.16.7
"@babel/plugin-transform-react-jsx-self": ^7.16.7
"@babel/plugin-transform-react-jsx-source": ^7.16.7
"@rollup/pluginutils": ^4.2.1
react-refresh: ^0.13.0
resolve: ^1.22.0
checksum: 0d386828bdc2a03251959638ccf326e9533e820ffb3108f7bba6112dd07021ec839498395d9345391ae9233b17dbb81a732ea9f8e021fc8904fccae844d008f2
languageName: node
linkType: hard

"@vitejs/plugin-react@npm:^2.0.0, @vitejs/plugin-react@npm:^2.0.1":
version: 2.0.1
resolution: "@vitejs/plugin-react@npm:2.0.1"
Expand Down Expand Up @@ -37474,6 +37562,13 @@ __metadata:
languageName: node
linkType: hard

"react-refresh@npm:^0.13.0":
version: 0.13.0
resolution: "react-refresh@npm:0.13.0"
checksum: cb9f324d471485e569628854dc08d1550c0798cde57f1bfb8d954e006659de1da0bdccaf7d5d2ac0d3d53df1aae7b740b2a36128789afb8aff0f7ec01b128587
languageName: node
linkType: hard

"react-refresh@npm:^0.14.0":
version: 0.14.0
resolution: "react-refresh@npm:0.14.0"
Expand Down
32 changes: 7 additions & 25 deletions scripts/tasks/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { join } from 'path';
import { pathExistsSync, readFile, writeFile } from 'fs-extra';

import { servePackages } from '../utils/serve-packages';
import type { Task } from '../task';
import { exec } from '../utils/exec';
Expand All @@ -17,31 +14,16 @@ export const testRunner: Task = {

// We could split this out into a separate task if it became annoying
const publishController = await servePackages({});
await exec(`yarn add --dev @storybook/test-runner jest-junit`, execOptions);

// Note we could split this out into a separate task too. We sort of do by checking if the file exists
const testFilePathname = join(sandboxDir, 'test-runner-jest.config.js');
if (junitFilename && !(await pathExistsSync(testFilePathname))) {
await exec(`yarn test-storybook --eject`, execOptions);
const testFile = await readFile(testFilePathname, 'utf8');

const reporters = `reporters: [
'default',
['jest-junit', {
outputDirectory: '${junitFilename}',
addFileAttribute: 'true',
usePathForSuiteName: 'true',
uniqueOutputName: 'true' },
],
],`;

const newTestFile = testFile.replace(/}\s*$/m, `${reporters}$&`);
await writeFile(testFilePathname, newTestFile);
}
await exec(`yarn add --dev @storybook/test-runner`, execOptions);

const storybookController = await serveSandbox(builtSandboxDir, {});

await exec(`yarn test-storybook --url http://localhost:8001`, execOptions);
await exec(`yarn test-storybook --url http://localhost:8001 --junit`, {
...execOptions,
env: {
JEST_JUNIT_OUTPUT_FILE: junitFilename,
},
});
yannbf marked this conversation as resolved.
Show resolved Hide resolved

publishController.abort();
storybookController.abort();
Expand Down