Skip to content

Commit

Permalink
test(cli): use it.each to improve test run output
Browse files Browse the repository at this point in the history
Co-authored-by: Gaëtan Maisse <gmaisse@solocal.com>
  • Loading branch information
jamesgeorge007 and gaetanmaisse committed Nov 26, 2020
1 parent b3eccc2 commit 922e9c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"scripts": {
"prepare": "node ../../scripts/prepare.js && node ./scripts/generate-sb-packages-versions.js",
"test": "jest test/**/*.test.js",
"test": "jest test/**/*.test.js --verbose",
"postversion": "node ./scripts/generate-sb-packages-versions.js"
},
"dependencies": {
Expand Down
24 changes: 10 additions & 14 deletions lib/cli/test/commands/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const fixturesDirPath = path.join(__dirname, '..', 'fixtures');
const runDirPath = path.join(__dirname, '..', 'run');

const rootPath = path.join(__dirname, '..', '..', '..', '..');
const dirs = fs.readdirSync(fixturesDirPath);

beforeAll(() => {
fse.removeSync(runDirPath);
fse.mkdirSync(runDirPath);
// Copy all files from fixtures directory to `run`
const dirs = fs.readdirSync(fixturesDirPath);
dirs.forEach((dir) => {
const src = path.join(fixturesDirPath, dir);
const dest = path.join(runDirPath, path.basename(src));
Expand All @@ -26,29 +26,25 @@ afterAll(() => {
});

describe('sb init', () => {
it('starts storybook without errors', () => {
const dirs = fs.readdirSync(runDirPath);
beforeAll(() => {
dirs.forEach((dir) => {
run(['init', '--skip-install', 'yes'], { cwd: path.join(runDirPath, dir) });
});

// Install all the dependencies in a single run
console.log('Running bootstrap');
run(
['yarn', 'install', '--non-interactive', '--silent', '--pure-lockfile'],
{ cwd: rootPath },
false
);

});
it.each(dirs)('starts storybook in smoke-test mode for: %s', (dir) => {
// Check that storybook starts without errors
dirs.forEach((dir) => {
console.log(`Running smoke test in ${dir}`);
const { status } = run(
['yarn', 'storybook', '--smoke-test', '--quiet'],
{ cwd: path.join(runDirPath, dir) },
false
);
expect(status).toBe(0);
});
const { status } = run(
['yarn', 'storybook', '--smoke-test', '--quiet'],
{ cwd: path.join(runDirPath, dir) },
false
);
expect(status).toBe(0);
});
});

0 comments on commit 922e9c3

Please sign in to comment.