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
Changes from 1 commit
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
29 changes: 7 additions & 22 deletions scripts/tasks/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,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/[email protected]`, 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