mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
import type { Task } from '../task';
|
|
import { exec } from '../utils/exec';
|
|
import { PORT } from './serve';
|
|
|
|
export const testRunnerBuild: Task & { port: number } = {
|
|
description: 'Run the test runner against a built sandbox',
|
|
junit: true,
|
|
dependsOn: ['serve'],
|
|
port: PORT,
|
|
async ready() {
|
|
return false;
|
|
},
|
|
async run({ sandboxDir, junitFilename, template }, { dryRun, debug }) {
|
|
const execOptions = { cwd: sandboxDir };
|
|
const flags = [
|
|
`--url http://localhost:${this.port}`,
|
|
'--junit',
|
|
'--maxWorkers=2',
|
|
'--failOnConsole',
|
|
'--skipTags="test-skip"',
|
|
];
|
|
|
|
// index-json mode is only supported in ssv7
|
|
if (template.modifications?.mainConfig?.features?.storyStoreV7 !== false) {
|
|
flags.push('--index-json');
|
|
}
|
|
|
|
await exec(
|
|
`yarn test-storybook ${flags.join(' ')}`,
|
|
{
|
|
...execOptions,
|
|
env: {
|
|
JEST_JUNIT_OUTPUT_FILE: junitFilename,
|
|
TEST_ROOT: sandboxDir,
|
|
},
|
|
},
|
|
{ dryRun, debug }
|
|
);
|
|
},
|
|
};
|