-
Notifications
You must be signed in to change notification settings - Fork 418
/
story-based-tests.dom-snapshot-test.js
47 lines (40 loc) · 2.05 KB
/
story-based-tests.dom-snapshot-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* STORY-BASED DOM SNAPSHOT TESTING
*
* This uses StoryShots to iterate over stories created in Storybook to
* automatically create DOM and image snapshot tests.
*
* For more information, please visit:
* https://github.com/storybooks/storybook/tree/master/addons/storyshots
*/
// Ran in Jest Node environment
import initStoryshots, {
multiSnapshotWithOptions,
} from '@storybook/addon-storyshots';
// Add tests to this file to exclude them from testing
import excludeFromTests from './exclude-story-config';
import { getExcludeKindRegex, skipStoryShotTest } from './storyshots-helpers';
console.log(`
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
QUEUEING: STORY-BASED DOM SNAPSHOT TESTING
★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
EXECUTING /tests/story-based-tests.dom.snapshot-test.js
BASED ON STORYBOOK STORIES FOUND IN /components/
This script uses Jest to call Storyshots
https://github.com/storybooks/storybook/tree/next/addons/storyshots on each
Storybook story found at http://localhost:9001. This stores a copy of the
DOM on load in a text file. If you need an open menu tested, then you will
need to open the menu with the \`isOpen\` prop.
For more information, please review: https://github.com/salesforce/design-system-react/blob/master/tests/README.md
`);
// Create DOM snapshot tests from Storybook stories
initStoryshots({
configPath: '.storybook',
storyNameRegex: new RegExp(`^((?!.*?(${skipStoryShotTest})).)*$`, 'g'),
storyKindRegex: getExcludeKindRegex({
arrayOfStoryKind: excludeFromTests.domSnapshot.storyKind,
}),
suite: 'DOM snapshots',
integrityOptions: { cwd: __dirname }, // start searching from the current directory
test: multiSnapshotWithOptions({}),
});