Remove jest_workaround by adding extra jest.mock functions

This commit is contained in:
Kasper Peulen 2023-02-24 16:49:04 +01:00
parent 94dea67f54
commit 63daf16055
11 changed files with 16 additions and 22 deletions

View File

@ -4,9 +4,6 @@ const path = require('path');
const swcrc = JSON.parse(fs.readFileSync('.swcrc', 'utf8'));
// This is needed for proper jest mocking, see https://github.com/swc-project/swc/discussions/5151#discussioncomment-3149154
((swcrc.jsc ??= {}).experimental ??= {}).plugins = [['jest_workaround', {}]];
/**
* TODO: Some windows related tasks are still commented out, because they are behaving differently on
* a local Windows machine compared to the Windows Server 2022 machine running in GitHub Actions.

View File

@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/types';
import type { PackageJson } from '../../js-package-manager';
import { autodocsTrue } from './autodocs-true';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
import { autodocsTrue } from './autodocs-true';
const checkAutodocs = async ({
packageJson = {},

View File

@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/types';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
import type { PackageJson } from '../../js-package-manager';
import { builderVite } from './builder-vite';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
const checkBuilderVite = async ({
packageJson = {},

View File

@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/types';
import type { PackageJson } from '../../js-package-manager';
import { cra5 } from './cra5';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
import { cra5 } from './cra5';
const checkCra5 = async ({
packageJson,

View File

@ -1,11 +1,14 @@
import type { StorybookConfig } from '@storybook/types';
import * as findUp from 'find-up';
import type { PackageJson } from '../../js-package-manager';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
import * as rendererHelpers from '../helpers/detectRenderer';
import { newFrameworks } from './new-frameworks';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
jest.mock('find-up');
jest.mock('../helpers/detectRenderer', () => ({
detectRenderer: jest.fn(jest.requireActual('../helpers/detectRenderer').detectRenderer),
}));
const checkNewFrameworks = async ({
packageJson,

View File

@ -1,5 +1,5 @@
import type { PackageJson } from '../../js-package-manager';
import { makePackageManager } from '../helpers/testing-helpers';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
import { sbBinary } from './sb-binary';
const checkStorybookBinary = async ({
@ -9,6 +9,7 @@ const checkStorybookBinary = async ({
packageJson: PackageJson;
storybookVersion?: string;
}) => {
mockStorybookData({ mainConfig: {}, storybookVersion });
return sbBinary.check({ packageManager: makePackageManager(packageJson) });
};

View File

@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/types';
import type { PackageJson } from '../../js-package-manager';
import { vue3 } from './vue3';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
import { vue3 } from './vue3';
const checkVue3 = async ({
packageJson,

View File

@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/types';
import type { PackageJson } from '../../js-package-manager';
import { webpack5 } from './webpack5';
import { makePackageManager, mockStorybookData } from '../helpers/testing-helpers';
import { webpack5 } from './webpack5';
const checkWebpack5 = async ({
packageJson,

View File

@ -2,6 +2,11 @@ import type { JsPackageManager, PackageJson } from '../../js-package-manager';
import type { GetStorybookData } from './mainConfigFile';
import * as mainConfigFile from './mainConfigFile';
jest.mock('./mainConfigFile', () => ({
...jest.requireActual('./mainConfigFile'),
getStorybookData: jest.fn(),
}));
jest.mock('@storybook/core-common', () => ({
...jest.requireActual('@storybook/core-common'),
loadMainConfig: jest.fn(),

View File

@ -241,7 +241,6 @@
"jest-os-detection": "^1.3.1",
"jest-serializer-html": "^7.1.0",
"jest-watch-typeahead": "^2.2.1",
"jest_workaround": "^0.1.14",
"lerna": "^6.4.0",
"lint-staged": "^10.5.4",
"lodash": "^4.17.21",

View File

@ -7159,7 +7159,6 @@ __metadata:
jest-os-detection: ^1.3.1
jest-serializer-html: ^7.1.0
jest-watch-typeahead: ^2.2.1
jest_workaround: ^0.1.14
lerna: ^6.4.0
lint-staged: ^10.5.4
lodash: ^4.17.21
@ -19664,16 +19663,6 @@ __metadata:
languageName: node
linkType: hard
"jest_workaround@npm:^0.1.14":
version: 0.1.14
resolution: "jest_workaround@npm:0.1.14"
peerDependencies:
"@swc/core": ^1.3.3
"@swc/jest": ^0.2.22
checksum: 98f02ade07d2d2befdac5ca27e0b3ea70b86c9b9fa54d21a1b41dee4672333df5d880ccc851771e43c16575f081d02a10d1de06cc90b33bcff7e5822e901815a
languageName: node
linkType: hard
"jju@npm:^1.4.0":
version: 1.4.0
resolution: "jju@npm:1.4.0"