Skip to content

Commit

Permalink
Revert "Fix esm only import from vitest"
Browse files Browse the repository at this point in the history
This reverts commit d4fa610.
  • Loading branch information
valentinpalkovic committed Nov 26, 2024
1 parent d4fa610 commit 91c76ac
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions code/addons/test/src/node/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import type {
import type { API_StatusUpdate } from '@storybook/types';

import type { Suite } from '@vitest/runner';
// TODO
// We can theoretically avoid the `@vitest/runner` dependency by copying over the necessary
// functions from the `@vitest/runner` package. It is not complex and does not have
// any significant dependencies.
import { getTests } from '@vitest/runner/utils';
import { throttle } from 'es-toolkit';

import { TEST_PROVIDER_ID } from '../constants';
Expand Down Expand Up @@ -68,13 +73,7 @@ export class StorybookReporter implements Reporter {
this.start = Date.now();
}

async getProgressReport(finishedAt?: number) {
// TODO
// We can theoretically avoid the `@vitest/runner` dependency by copying over the necessary
// functions from the `@vitest/runner` package. It is not complex and does not have
// any significant dependencies.
const { getTests } = await import('@vitest/runner/utils');

getProgressReport(finishedAt?: number) {
const files = this.ctx.state.getFiles();
const fileTests = getTests(files).filter((t) => t.mode === 'run' || t.mode === 'only');

Expand Down Expand Up @@ -161,7 +160,7 @@ export class StorybookReporter implements Reporter {
this.sendReport({
providerId: TEST_PROVIDER_ID,
status: 'pending',
...(await this.getProgressReport()),
...this.getProgressReport(),
});
} catch (e) {
this.sendReport({
Expand Down Expand Up @@ -192,7 +191,7 @@ export class StorybookReporter implements Reporter {
const unhandledErrors = this.ctx.state.getUnhandledErrors();

const isCancelled = this.ctx.isCancelling;
const report = await this.getProgressReport(Date.now());
const report = this.getProgressReport(Date.now());

const testSuiteFailures = report.details.testResults.filter(
(t) => t.status === 'failed' && t.results.length === 0
Expand Down

0 comments on commit 91c76ac

Please sign in to comment.