Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: E2E tests for new Component Testing features #29826

Merged
merged 40 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
82e0c62
ugprade vitest dependencies to 2.1.6
JReinhold Dec 3, 2024
1373b36
improve type-safety in coverage reporter
JReinhold Dec 3, 2024
e111a2d
add coverage E2E test, a11y labels to coverage UI
JReinhold Dec 3, 2024
291a70a
Merge branch 'next' of github.com:storybookjs/storybook into 29745-e2…
JReinhold Dec 4, 2024
1dd20b7
Merge branch 'norbert/vitest-support-preview-html' of github.com:stor…
JReinhold Dec 5, 2024
c91f604
commit stuff - not done
JReinhold Dec 5, 2024
eb1a526
add an experimentalLoadStorybook api
ndelangen Dec 5, 2024
41a0c7a
cleanup
ndelangen Dec 5, 2024
6f48ea8
fix coverage+watch test
JReinhold Dec 5, 2024
269f1a2
fix tests
JReinhold Dec 5, 2024
0c76a0e
Merge branch 'norbert/vitest-support-preview-html' into 29745-e2e-tes…
JReinhold Dec 5, 2024
bc52357
fix story types
JReinhold Dec 5, 2024
b4154f5
Merge branch '29745-e2e-tests-for-testing-improvements' of github.com…
JReinhold Dec 5, 2024
87fa9ba
better comments
JReinhold Dec 5, 2024
23f4967
add non-failing-vitest to ci
JReinhold Dec 5, 2024
d1441aa
fix vitest/ui dep
JReinhold Dec 6, 2024
b5b65b0
simplify coverage+focus test
JReinhold Dec 6, 2024
1b86bf3
revert vitest upgrades
JReinhold Dec 6, 2024
a5034d8
Merge branch 'norbert/vitest-support-preview-html' into 29745-e2e-tes…
JReinhold Dec 6, 2024
ab5be7f
Merge branch 'norbert/vitest-support-preview-html' of github.com:stor…
JReinhold Dec 6, 2024
5a9ba43
Merge branch '29745-e2e-tests-for-testing-improvements' of github.com…
JReinhold Dec 6, 2024
b8c9393
revert yarn.lock changes.
JReinhold Dec 6, 2024
f47acc5
add staticDirs test
JReinhold Dec 9, 2024
0a5a607
add test for vitefinal
JReinhold Dec 10, 2024
b4f4965
Merge branch 'norbert/vitest-support-preview-html' of github.com:stor…
JReinhold Dec 10, 2024
5813cd4
Merge branch 'norbert/vitest-support-preview-html' of github.com:stor…
JReinhold Dec 10, 2024
17a01ee
cleanup
JReinhold Dec 10, 2024
0367631
Merge branch 'next' of github.com:storybookjs/storybook into 29745-e2…
JReinhold Dec 10, 2024
11a25dc
cleanup
JReinhold Dec 10, 2024
58afdd4
Merge branch 'jeppe/fix-duplicate-include' of github.com:storybookjs/…
JReinhold Dec 12, 2024
e7a5eb2
Merge branch 'next' of github.com:storybookjs/storybook into 29745-e2…
JReinhold Dec 12, 2024
65f6411
fix e2e tests 🤞
JReinhold Dec 12, 2024
0225d09
speedup kitchen sink storybook
JReinhold Dec 12, 2024
1765262
add fail-on-purpose tag to Button story
JReinhold Dec 12, 2024
64d9692
Merge branch 'next' into 29745-e2e-tests-for-testing-improvements
JReinhold Dec 15, 2024
8128b6f
Merge branch 'next' into 29745-e2e-tests-for-testing-improvements
ndelangen Dec 16, 2024
041d195
Update code/addons/test/src/components/TestProviderRender.tsx
JReinhold Dec 17, 2024
a2dc9e1
Merge branch 'next' into 29745-e2e-tests-for-testing-improvements
JReinhold Dec 17, 2024
1fca1f6
fix format
JReinhold Dec 17, 2024
a19b0f5
reuse existing vitest script
JReinhold Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,10 @@ jobs:
name: Run E2E tests
command: yarn playwright-e2e
working_directory: test-storybooks/portable-stories-kitchen-sink/react
- run:
name: Run Vitest
Copy link
Member

@yannbf yannbf Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? If you want the vitest script to be tested as part of CI, just move the contents of vitest-skip-fail-on-purpose and move it to vitest, which will be automatically run as part of this CI step:
https://github.com/storybookjs/storybook/blob/29745-e2e-tests-for-testing-improvements/.circleci/config.yml#L794

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah that's much better, it's to test these scenarios: https://github.com/storybookjs/storybook/pull/29826/files#diff-0550ef2a360c5242f25677cd964d3afce1c0412497a76eded7d03c0838941611R68-R92

Another alternative would be to move those stories into the UI Storybook instead, no strong opinion.

command: yarn vitest-skip-fail-on-purpose
working_directory: test-storybooks/portable-stories-kitchen-sink/react
- store_test_results:
path: test-results
- store_artifacts:
Expand Down
7 changes: 6 additions & 1 deletion code/addons/test/src/components/TestProviderRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,19 @@ export const TestProviderRender: FC<
href={'/coverage/index.html'}
// @ts-expect-error ListItem doesn't include all anchor attributes in types, but it is an achor element
target="_blank"
aria-label="Open coverage report"
JReinhold marked this conversation as resolved.
Show resolved Hide resolved
icon={
<TestStatusIcon
percentage={coverageSummary.percentage}
status={coverageSummary.status}
aria-label={`status: ${coverageSummary.status}`}
/>
}
right={`${coverageSummary.percentage}%`}
right={
<span aria-label={`${coverageSummary.percentage} percent coverage`}>
{coverageSummary.percentage} %
JReinhold marked this conversation as resolved.
Show resolved Hide resolved
</span>
JReinhold marked this conversation as resolved.
Show resolved Hide resolved
}
/>
) : (
<ListItem
Expand Down
4 changes: 2 additions & 2 deletions code/addons/test/src/node/coverage-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { TestManager } from './test-manager';

export type StorybookCoverageReporterOptions = {
testManager: TestManager;
coverageOptions: ResolvedCoverageOptions<'v8'>;
coverageOptions: ResolvedCoverageOptions<'v8'> | undefined;
};

export default class StorybookCoverageReporter extends ReportBase implements Partial<Visitor> {
Expand All @@ -32,7 +32,7 @@ export default class StorybookCoverageReporter extends ReportBase implements Par

// Fallback to Vitest's default watermarks https://vitest.dev/config/#coverage-watermarks
const [lowWatermark = 50, highWatermark = 80] =
this.#coverageOptions.watermarks?.statements ?? [];
this.#coverageOptions?.watermarks?.statements ?? [];

const coverageDetails: Details['coverageSummary'] = {
percentage,
Expand Down
2 changes: 1 addition & 1 deletion code/addons/test/src/node/vitest-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class VitestManager {
join(packageDir, 'dist/node/coverage-reporter.js'),
{
testManager: this.testManager,
coverageOptions: this.vitest?.config?.coverage as ResolvedCoverageOptions<'v8'>,
coverageOptions: this.vitest?.config?.coverage as ResolvedCoverageOptions<'v8'> | undefined,
},
];
const coverageOptions = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// This file is used to test that viteFinal is correctly loaded in Vitest
// main.ts defines this file as a resolve alias, which is used in the ViteFinalTest story

export const aliasedFunction = () => true;
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { StorybookConfig } from "@storybook/react-vite";
import { join } from 'path';

const config: StorybookConfig = {
stories: ["../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
Expand Down Expand Up @@ -32,5 +33,18 @@ const config: StorybookConfig = {
border: 1px solid red;
}
</style>`,
staticDirs: [{ from: './test-static-dirs', to:'test-static-dirs' }],
JReinhold marked this conversation as resolved.
Show resolved Hide resolved
viteFinal: (config) => {
return {
...config,
resolve: {
...config.resolve,
alias: {
...config.resolve?.alias,
'test-alias': join(__dirname, 'aliased.ts'),
},
}
};
},
};
export default config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file is used to test that staticDirs are correctly loaded in Vitest

export const staticFunction = () => true;
Loading
Loading