Skip to content

Commit

Permalink
Merge branch 'next' into jeppe/improve-coverage-error
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold authored Dec 17, 2024
2 parents dcd5549 + 438393a commit d51634e
Show file tree
Hide file tree
Showing 14 changed files with 702 additions and 239 deletions.
9 changes: 8 additions & 1 deletion code/addons/test/src/components/TestProviderRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,21 @@ 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"
icon={
<TestStatusIcon
percentage={coverageSummary.percentage}
status={coverageSummary.status}
aria-label={`status: ${coverageSummary.status}`}
/>
}
right={coverageSummary.percentage ? `${coverageSummary.percentage}%` : null}
right={
coverageSummary.percentage ? (
<span aria-label={`${coverageSummary.percentage} percent coverage`}>
{coverageSummary.percentage} %
</span>
) : null
}
/>
) : (
<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' }],
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

0 comments on commit d51634e

Please sign in to comment.