Skip to content

Commit

Permalink
Merge pull request #141 from storybookjs/yann/allow-storybook-test
Browse files Browse the repository at this point in the history
use-storybook-expect: allow @storybook/test imports
  • Loading branch information
yannbf authored Sep 20, 2023
2 parents 611b70e + 5447e45 commit f1ffa5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rules/use-storybook-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ export = createStorybookRule<TDefaultOptions, string>({
//----------------------------------------------------------------------

const isExpectFromStorybookImported = (node: TSESTree.ImportDeclaration) => {
const { value: packageName } = node.source
const usesExpectFromStorybook =
packageName === '@storybook/jest' || packageName === '@storybook/test'
return (
node.source.value === '@storybook/jest' &&
usesExpectFromStorybook &&
node.specifiers.find((spec) => isImportSpecifier(spec) && spec.imported.name === 'expect')
)
}
Expand Down
17 changes: 17 additions & 0 deletions tests/lib/rules/use-storybook-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ ruleTester.run('use-storybook-expect', rule, {
dedent`
import { expect } from '@storybook/jest';
export const Basic = {
...Default,
play: async (context) => {
expect(123).toEqual(123);
},
};
`,
dedent`
import { expect } from '@storybook/test';
Default.play = () => {
expect(123).toEqual(123);
}
`,
dedent`
import { expect } from '@storybook/test';
export const Basic = {
...Default,
play: async (context) => {
Expand Down

0 comments on commit f1ffa5e

Please sign in to comment.