Skip to content

Commit 1319396

Browse files
Merge pull request #1383 from interactivellama/storyshots-tests
Improve Storyshots tests experience
2 parents 8c85f69 + d723c0d commit 1319396

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

app.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
/* eslint-disable import/no-extraneous-dependencies */
44
const compression = require('compression');
55
const express = require('express');
6+
const minimist = require('minimist');
67

78
const port = process.env.PORT || 9001;
9+
const argv = minimist(process.argv.slice(2));
10+
const buildFolder = argv.folder || 'storybook';
11+
// Setting buildFolder to 'storybook-based-tests' will allow interactive viewing of the Storyshots (story based tests).
812

913
// Create server
1014
const app = express();
@@ -19,10 +23,7 @@ app.use(
1923
`${__dirname}/node_modules/@salesforce-ux/design-system/assets/`
2024
)
2125
);
22-
app.use(express.static(`${__dirname}/storybook`));
23-
24-
// Use the following line to test Storyshots instead
25-
// app.use(express.static(`${__dirname}/storybook-based-tests`));
26+
app.use(express.static(`${__dirname}/${buildFolder}`));
2627

2728
// Listen
2829
const server = app.listen(port, () => {

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
"scripts": {
1111
"build-docs": "npx babel-node ./scripts/build-docs.js",
1212
"build-and-test-docs": "npm run build-docs && npx babel-node ./tests/component-docs-test.js",
13-
"build-storybook": "NODE_ENV=development npx build-storybook -o ./storybook",
14-
"build-storybook-for-tests": "NODE_ENV=development npx build-storybook -o ./storybook-based-tests -c ./.storybook-based-tests",
1513
"dist": "scripts/dist.sh",
1614
"heroku-prebuild": "./scripts/heroku-prebuild.sh",
1715
"heroku-postbuild": "./scripts/heroku-postbuild.sh",
@@ -27,10 +25,12 @@
2725
"publish:upstream": "npx babel-node scripts/publish-to-git.js --remote=upstream",
2826
"release:patch": "npx babel-node scripts/release.js --release=patch",
2927
"release:minor": "npx babel-node scripts/release.js --release=minor",
30-
"snapshot-test": "npx jest",
28+
"snapshot-test": "npm run storyshots:build && npx jest",
3129
"start": "npx start-storybook -p 9001 -s ./node_modules & node tests/browser-tests-app",
32-
"start:static": "node app",
33-
"storybook": "start-storybook -p 9001 -s ./node_modules",
30+
"static:start": "node app",
31+
"static:build": "NODE_ENV=development npx build-storybook -o ./storybook",
32+
"storyshots:build": "NODE_ENV=development npx build-storybook -o ./storybook-based-tests -c ./.storybook-based-tests",
33+
"storyshots:start": "node app --folder=storybook-based-tests",
3434
"test": "scripts/local-qa.sh --no-fix",
3535
"test:fix": "scripts/local-qa.sh",
3636
"travis-ci": "scripts/travis-ci.sh",

scripts/heroku-postbuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
echo "# Building for Heroku"
77

8-
npm run build-storybook
8+
npm run static:build

tests/story-based-tests.snapshot-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import express from 'express';
1212
import initStoryshots, { imageSnapshot } from '@storybook/addon-storyshots';
1313
import path from 'path';
1414

15-
// Express server setup. `npm run build-storybook-image-test` must
15+
// Express server setup. `npm run storyshots:build` must
1616
// be run first.
1717
const rootPath = path.resolve(__dirname, '../');
1818
const app = express();

0 commit comments

Comments
 (0)