Skip to content

Commit

Permalink
Merge pull request #28222 from storybookjs/norbert/happy-dom
Browse files Browse the repository at this point in the history
Build: Migrate to `happy-dom`, use `vitest` `node-environment` by default
  • Loading branch information
ndelangen authored Jun 12, 2024
2 parents 280e9a4 + 7495940 commit bb3d8cc
Show file tree
Hide file tree
Showing 107 changed files with 165 additions and 528 deletions.
9 changes: 1 addition & 8 deletions code/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,7 @@ module.exports = {
},
},
{
files: ['**/template/**/*'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
{
// this package depends on a lot of peerDependencies we don't want to specify, because npm would install them
files: ['**/addons/docs/**/*'],
files: ['**/template/**/*', '**/vitest.config.ts', '**/addons/docs/**/*'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
Expand Down
2 changes: 2 additions & 0 deletions code/addons/a11y/src/components/A11YPanel.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
import React from 'react';
import { render, waitFor, fireEvent, act, cleanup } from '@testing-library/react';
Expand Down
2 changes: 2 additions & 0 deletions code/addons/a11y/src/components/A11yContext.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
import * as React from 'react';
import type { AxeResults } from 'axe-core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import { describe, it, expect, afterEach, vi } from 'vitest';
import React from 'react';
import { render, fireEvent, cleanup } from '@testing-library/react';
Expand Down
4 changes: 1 addition & 3 deletions code/addons/a11y/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/actions/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/backgrounds/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/controls/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/docs/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/essentials/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/gfm/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/highlight/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/interactions/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/jest/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
2 changes: 2 additions & 0 deletions code/addons/links/src/react/components/link.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

/// <reference types="@testing-library/jest-dom" />;
import { describe, it, expect, afterEach, vi } from 'vitest';
import React from 'react';
Expand Down
2 changes: 2 additions & 0 deletions code/addons/links/src/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import { describe, beforeAll, beforeEach, it, expect, vi } from 'vitest';
import { addons } from '@storybook/preview-api';
import { SELECT_STORY } from '@storybook/core-events';
Expand Down
4 changes: 1 addition & 3 deletions code/addons/links/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/measure/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
2 changes: 1 addition & 1 deletion code/addons/onboarding/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: { environment: 'jsdom' },
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/outline/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/storysource/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/themes/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/toolbars/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
4 changes: 1 addition & 3 deletions code/addons/viewport/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vitestCommonConfig } from '../../vitest.workspace';
export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'jsdom',
},
// Add custom config here
})
);
6 changes: 2 additions & 4 deletions code/builders/builder-manager/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'node',
},
// Add custom config here
})
);
6 changes: 2 additions & 4 deletions code/builders/builder-vite/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'node',
},
// Add custom config here
})
);
6 changes: 2 additions & 4 deletions code/builders/builder-webpack5/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'node',
},
// Add custom config here
})
);
1 change: 0 additions & 1 deletion code/frameworks/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
"@types/cross-spawn": "^6.0.2",
"@types/tmp": "^0.2.3",
"cross-spawn": "^7.0.3",
"jsdom": "^23.0.1",
"tmp": "^0.2.1",
"typescript": "^5.3.2",
"webpack": "5",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* @vitest-environment node
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { vi, describe, beforeEach, expect, it, afterEach } from 'vitest';
import { Architect, createBuilder } from '@angular-devkit/architect';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* @vitest-environment node
*/

// eslint-disable-next-line import/no-extraneous-dependencies
import { vi, describe, expect, it, beforeEach, afterEach } from 'vitest';
import { Architect, createBuilder } from '@angular-devkit/architect';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';
import { Component, ɵresetJitOptions } from '@angular/core';
import { platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import { NgModule, Component, EventEmitter, Input, Output } from '@angular/core';
import { describe, expect, it } from 'vitest';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import { Subject, lastValueFrom } from 'rxjs';
import { vi, describe, it, expect, beforeEach, afterEach } from 'vitest';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @vitest-environment happy-dom

import {
Type,
Component,
Expand Down
12 changes: 6 additions & 6 deletions code/frameworks/angular/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default defineConfig(({ mode }) => {
return mergeConfig(vitestCommonConfig, {
export default mergeConfig(
vitestCommonConfig,
defineConfig({
// Add custom config here
test: {
setupFiles: ['src/test-setup.ts'],
environment: 'jsdom',
},
});
});
})
);
5 changes: 1 addition & 4 deletions code/frameworks/ember/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/* eslint-disable import/no-extraneous-dependencies */
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'node',
},
// Add custom config here
})
);
6 changes: 2 additions & 4 deletions code/frameworks/html-webpack5/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'node',
},
// Add custom config here
})
);
6 changes: 2 additions & 4 deletions code/frameworks/nextjs/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'node',
},
// Add custom config here
})
);
6 changes: 2 additions & 4 deletions code/frameworks/preact-vite/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* eslint-disable import/no-extraneous-dependencies */
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig, mergeConfig } from 'vitest/config';
import { vitestCommonConfig } from '../../vitest.workspace';

export default mergeConfig(
vitestCommonConfig,
defineConfig({
test: {
environment: 'node',
},
// Add custom config here
})
);
Loading

0 comments on commit bb3d8cc

Please sign in to comment.