Skip to content

Commit

Permalink
Merge pull request #335 from storybookjs/next
Browse files Browse the repository at this point in the history
Release 0.12.0
  • Loading branch information
yannbf authored Jul 27, 2023
2 parents 2cec20a + 137a7ee commit 4b6169f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @yannbf @kasperpeulen
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,14 @@ test:
- name: Testing storybook
run: yarn test-storybook --coverage --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Renaming coverage file
uses: mv coverage/storybook/coverage-storybook.json coverage/storybook/coverage-storybook-${matrix.shard}.json
run: mv coverage/storybook/coverage-storybook.json coverage/storybook/coverage-storybook-${matrix.shard}.json
report-coverage:
name: Reporting storybook coverage
steps:
- name: Merging coverage
uses: yarn nyc merge coverage/storybook merged-output/merged-coverage.json
run: yarn nyc merge coverage/storybook merged-output/merged-coverage.json
- name: Report coverage
uses: yarn nyc report --reporter=text -t merged-output --report-dir merged-output
run: yarn nyc report --reporter=text -t merged-output --report-dir merged-output
```

Circle CI example:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"build:watch": "tsup --watch",
"test": "jest",
"storybook": "storybook dev -p 6006",
"start": "concurrently \"yarn build:watch\" \"yarn storybook -- --no-manager-cache --quiet\"",
"start": "concurrently \"yarn build:watch\" \"yarn storybook -- --quiet\"",
"build-storybook": "storybook build",
"release": "yarn build && auto shipit",
"test-storybook": "node dist/test-storybook",
Expand Down
2 changes: 1 addition & 1 deletion src/test-storybook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function reportCoverage() {

const onProcessEnd = () => {
cleanup();
if (process.env.STORYBOOK_COLLECT_COVERAGE !== 'true') {
if (process.env.STORYBOOK_COLLECT_COVERAGE === 'true') {
reportCoverage();
}
};
Expand Down
18 changes: 17 additions & 1 deletion src/util/getCliOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@ import { getCliOptions } from './getCliOptions';
import * as cliHelper from './getParsedCliOptions';

describe('getCliOptions', () => {
let originalArgv: string[] = process.argv;

afterEach(() => {
process.argv = originalArgv;
});

it('returns custom options if passed', () => {
const customConfig = { configDir: 'custom', indexJson: true };
jest
.spyOn(cliHelper, 'getParsedCliOptions')
.mockReturnValue({ options: customConfig, extraArgs: [] });
.mockReturnValueOnce({ options: customConfig, extraArgs: [] });
const opts = getCliOptions();
expect(opts.runnerOptions).toMatchObject(customConfig);
});

it('returns extra args if passed', () => {
const extraArgs = ['TestName', 'AnotherTestName'];
// mock argv to avoid side effect from running tests e.g. jest --coverage,
// which would end up caught by getCliOptions
process.argv = [];
jest.spyOn(cliHelper, 'getParsedCliOptions').mockReturnValueOnce({ options: {}, extraArgs });
const opts = getCliOptions();
expect(opts.jestOptions).toEqual(extraArgs);
});
});
6 changes: 2 additions & 4 deletions src/util/getCliOptions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { getParsedCliOptions } from './getParsedCliOptions';
import type { BrowserType } from 'jest-playwright-preset';

export type JestOptions = {
[key: string]: any;
};
export type JestOptions = string[];

export type CliOptions = {
runnerOptions: {
Expand Down Expand Up @@ -63,7 +61,7 @@ export const getCliOptions = (): CliOptions => {
}, defaultOptions);

if (extraArgs.length) {
finalOptions.jestOptions.push(...[extraArgs]);
finalOptions.jestOptions.push(...extraArgs);
}

return finalOptions;
Expand Down

0 comments on commit 4b6169f

Please sign in to comment.