mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
CHANGE jest addon (merge in https://github.com/storybooks/storybook-addon-jest/pull/12)
This commit is contained in:
parent
5133d41f16
commit
7aa23d42f2
@ -31,6 +31,7 @@
|
||||
"global": "^4.3.2",
|
||||
"prop-types": "^15.6.2",
|
||||
"react-emotion": "^9.2.6",
|
||||
"upath": "^1.0.4",
|
||||
"util-deprecate": "^1.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
@ -1,17 +1,18 @@
|
||||
import addons from '@storybook/addons';
|
||||
import deprecate from 'util-deprecate';
|
||||
import { normalize } from 'upath';
|
||||
|
||||
const findTestResults = (testFiles, jestTestResults, jestTestFilesExt) =>
|
||||
const findTestResults = (testFiles, jestTestResults, jestTestFilesOptions) =>
|
||||
Object.values(testFiles).map(name => {
|
||||
const fileName = `${name}${jestTestFilesOptions.filesExt}`;
|
||||
if (jestTestResults && jestTestResults.testResults) {
|
||||
return {
|
||||
fileName,
|
||||
name,
|
||||
result: jestTestResults.testResults.find(t =>
|
||||
new RegExp(`${name}${jestTestFilesExt}`).test(t.name)
|
||||
),
|
||||
result: jestTestResults.testResults.find(t => normalize(t.name).includes(fileName)),
|
||||
};
|
||||
}
|
||||
return { name };
|
||||
return { fileName, name };
|
||||
});
|
||||
|
||||
const emitAddTests = ({ kind, story, testFiles, options }) => {
|
||||
|
@ -7,7 +7,7 @@ import Panel from './components/Panel';
|
||||
addons.register('storybook/tests', api => {
|
||||
const channel = addons.getChannel();
|
||||
addons.addPanel('storybook/tests/panel', {
|
||||
title: <PanelTitle channel={addons.getChannel()} api={api} />,
|
||||
title: <PanelTitle channel={channel} api={api} />,
|
||||
// eslint-disable-next-line react/prop-types
|
||||
render: ({ active }) => <Panel channel={channel} api={api} active={active} />,
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user