generated from storybookjs/addon-kit
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from storybookjs/feat/respect-mainjs-globs
Respect stories defined in main.js
- Loading branch information
Showing
50 changed files
with
235 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
Binary file renamed
BIN
+6.85 KB
__snapshots__/basic-button--primary-snap.png → __snapshots__/atoms-button--primary-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,9 @@ | ||
const { TEST_ROOT, TEST_MATCH } = process.env; | ||
|
||
const roots = TEST_ROOT ? [TEST_ROOT] : undefined; | ||
const { getJestConfig } = require('@storybook/test-runner'); | ||
|
||
module.exports = { | ||
cacheDirectory: 'node_modules/.cache/storybook/test-runner', | ||
rootDir: process.cwd(), | ||
roots, | ||
testMatch: [TEST_MATCH || '**/*.stories.[jt]s?(x)'], | ||
transform: { | ||
'^.+\\.stories\\.[jt]sx?$': '@storybook/test-runner/playwright/transform', | ||
'^.+\\.[jt]sx?$': 'babel-jest', | ||
}, | ||
preset: 'jest-playwright-preset', | ||
globalSetup: '@storybook/test-runner/playwright/global-setup.js', | ||
globalTeardown: '@storybook/test-runner/playwright/global-teardown.js', | ||
testEnvironment: '@storybook/test-runner/playwright/custom-environment.js', | ||
}; | ||
// The default configuration comes from @storybook/test-runner | ||
...getJestConfig() | ||
/** Add your own overrides below | ||
* @see https://jestjs.io/docs/configuration | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export const getJestConfig = () => { | ||
const { TEST_ROOT, TEST_MATCH, STORYBOOK_STORIES_PATTERN } = process.env; | ||
|
||
let config = { | ||
rootDir: process.cwd(), | ||
roots: TEST_ROOT ? [TEST_ROOT] : undefined, | ||
testMatch: STORYBOOK_STORIES_PATTERN && STORYBOOK_STORIES_PATTERN.split(';'), | ||
transform: { | ||
'^.+\\.stories\\.[jt]sx?$': '@storybook/test-runner/playwright/transform', | ||
'^.+\\.[jt]sx?$': 'babel-jest', | ||
}, | ||
preset: 'jest-playwright-preset', | ||
globalSetup: '@storybook/test-runner/playwright/global-setup.js', | ||
globalTeardown: '@storybook/test-runner/playwright/global-teardown.js', | ||
testEnvironment: '@storybook/test-runner/playwright/custom-environment.js', | ||
// @TODO: setupFilesAfterEnv: ['@storybook/test-runner/setup'] | ||
}; | ||
|
||
if (TEST_MATCH) { | ||
config.testMatch = [TEST_MATCH]; | ||
} | ||
|
||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './playwright/hooks'; | ||
export * from './config/jest-playwright'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { defaultRunnerOptions, getCliOptions } from './getCliOptions'; | ||
import * as cliHelper from './getParsedCliOptions'; | ||
|
||
describe('getCliOptions', () => { | ||
it('returns default options if no extra option is passed', () => { | ||
const opts = getCliOptions(); | ||
expect(opts.runnerOptions).toMatchObject(defaultRunnerOptions); | ||
}); | ||
|
||
it('returns custom options if passed', () => { | ||
const customConfig = { configDir: 'custom', storiesJson: true }; | ||
jest | ||
.spyOn(cliHelper, 'getParsedCliOptions') | ||
.mockReturnValue({ options: customConfig, extraArgs: [] }); | ||
const opts = getCliOptions(); | ||
expect(opts.runnerOptions).toMatchObject(customConfig); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { getStorybookMain } from './getStorybookMain'; | ||
import * as coreCommon from '@storybook/core-common'; | ||
|
||
jest.mock('@storybook/core-common'); | ||
|
||
describe('getStorybookMain', () => { | ||
it('should throw an error if no configuration is found', () => { | ||
expect(() => getStorybookMain('.storybook')).toThrow(); | ||
}); | ||
|
||
it('should return mainjs', () => { | ||
const mockedMain = { | ||
stories: [ | ||
{ | ||
directory: '../stories/basic', | ||
titlePrefix: 'Example', | ||
}, | ||
], | ||
}; | ||
|
||
jest.spyOn(coreCommon, 'serverRequire').mockImplementation(() => mockedMain); | ||
|
||
const res = getStorybookMain('.storybook'); | ||
expect(res).toMatchObject(mockedMain); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { join, resolve } from 'path'; | ||
import { serverRequire } from '@storybook/core-common'; | ||
import type { StorybookConfig } from '@storybook/core-common'; | ||
|
||
let storybookMainConfig: StorybookConfig; | ||
|
||
export const getStorybookMain = (configDir: string) => { | ||
if (storybookMainConfig) { | ||
return storybookMainConfig; | ||
} | ||
|
||
storybookMainConfig = serverRequire(join(resolve(configDir), 'main')); | ||
if (!storybookMainConfig) { | ||
throw new Error( | ||
`Could not load main.js in ${configDir}. Is the config directory correct? You can change it by using --config-dir <path-to-dir>` | ||
); | ||
} | ||
|
||
return storybookMainConfig; | ||
}; |
Oops, something went wrong.