-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
storyshot.configFunc.test.js
44 lines (38 loc) · 1.3 KB
/
storyshot.configFunc.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
import path from 'path';
import initStoryshots, { multiSnapshotWithOptions, Stories2SnapsConverter } from '../dist/ts3.9';
class AnotherStories2SnapsConverter extends Stories2SnapsConverter {
getSnapshotFileName(context) {
const { fileName, kind, name } = context;
const { dir, name: filename } = path.parse(fileName);
const uniqueName = `${filename}@${kind.replace(/ /g, '-_-')}@${name.replace(/ /g, '-_-')}`;
const { snapshotsDirName, snapshotExtension } = this.options;
return path.format({
dir: path.join(dir, snapshotsDirName),
name: uniqueName,
ext: snapshotExtension,
});
}
getPossibleStoriesFiles(storyshotFile) {
const { dir, name } = path.parse(storyshotFile);
const { storiesExtensions } = this.options;
const [fileName] = name.split('@');
return storiesExtensions.map((ext) =>
path.format({
dir: path.dirname(dir),
name: fileName,
ext,
})
);
}
}
initStoryshots({
framework: 'react',
integrityOptions: { cwd: __dirname },
stories2snapsConverter: new AnotherStories2SnapsConverter({ snapshotExtension: '.boo' }),
config: ({ configure }) =>
configure(() => {
// eslint-disable-next-line global-require
require('./directly_required');
}, module),
test: multiSnapshotWithOptions(),
});