Skip to content

Commit

Permalink
fix: support storybook6 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshah98 committed Oct 24, 2023
1 parent 9289b33 commit 2e37163
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"clean": "git clean -Xdf -e !node_modules -e !node_modules/**",
"lint": "eslint --ignore-path .gitignore .",
"readme": "percy-cli-readme",
"pretest": "storybook build --config-dir=./test/.storybook --output-dir=./test/.storybook-build --loglevel error",
"pretest": "build-storybook --config-dir=./test/.storybook --output-dir=./test/.storybook-build --loglevel error",
"test": "yarn test:env jasmine --config=./test/jasmine.json",
"test:env": "cross-env NODE_ENV=test NODE_OPTIONS='--loader=./test/loader.js'",
"test:coverage": "nyc yarn test"
Expand Down
6 changes: 3 additions & 3 deletions src/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export const start = command('start', {
let { default: { spawn } } = yield import('cross-spawn');
let { host, port } = flags;

let args = ['dev', '--ci', `--host=${host}`, `--port=${port}`, ...argv];
log.info(`Running "storybook ${args.join(' ')}"`);
let args = ['--ci', `--host=${host}`, `--port=${port}`, ...argv];
log.info(`Running "start-storybook ${args.join(' ')}"`);

let proc = yield new Promise((resolve, reject) => resolve(
spawn('storybook', args, { stdio: 'inherit' }).on('error', reject)
spawn('start-storybook', args, { stdio: 'inherit' }).on('error', reject)
));

/* istanbul ignore next: this is a storybook flag we don't need to test */
Expand Down
4 changes: 0 additions & 4 deletions test/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ module.exports = {
stories: ['*.stories.js'],
features: {
postcss: false
},
framework: {
name: '@storybook/react-webpack5',
options: {}
}
};
4 changes: 2 additions & 2 deletions test/storybook-start.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('percy storybook:start', () => {
] : []);

expect(logger.stdout).toEqual(jasmine.arrayContaining([
`[percy] Running "storybook dev --ci --host=localhost --port=9000 ${args.join(' ')}"`,
`[percy] Running "start-storybook --ci --host=localhost --port=9000 ${args.join(' ')}"`,
'[percy] Percy has started!',
'[percy] Snapshot taken: Snapshot: First',
'[percy] Snapshot taken: Snapshot: Second',
Expand All @@ -51,7 +51,7 @@ describe('percy storybook:start', () => {
await expectAsync(start([...args])).toBeRejectedWithError('FAKE ENOENT');

expect(logger.stdout).toEqual([
`[percy] Running "storybook dev --ci --host=localhost --port=9000 ${args.join(' ')}"`
`[percy] Running "start-storybook --ci --host=localhost --port=9000 ${args.join(' ')}"`
]);
expect(logger.stderr).toEqual([
'[percy] Error: FAKE ENOENT'
Expand Down
3 changes: 1 addition & 2 deletions test/storybook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ describe('percy storybook', () => {
default: () => [200, 'text/html', '<p>Not Storybook</p>']
});

proc = spawn('storybook', [
'dev',
proc = spawn('start-storybook', [
'--config-dir=./test/.storybook',
'--port=9000',
'--ci'
Expand Down

0 comments on commit 2e37163

Please sign in to comment.