mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
Fix Angular tests
This commit is contained in:
parent
c16c125385
commit
205a339707
@ -1,29 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
displayName: __dirname.split(sep).slice(-2).join(posix.sep),
|
|
||||||
preset: 'jest-preset-angular/presets/defaults-esm',
|
|
||||||
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
|
|
||||||
transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid)'],
|
|
||||||
snapshotFormat: {
|
|
||||||
escapeString: true,
|
|
||||||
printBasicPrototype: true,
|
|
||||||
},
|
|
||||||
coverageDirectory: './coverage/testapp',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.(ts|mjs|js|html)$': [
|
|
||||||
'jest-preset-angular',
|
|
||||||
{
|
|
||||||
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
||||||
stringifyContentPathRegex: '\\.(html|svg)$',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
snapshotSerializers: [
|
|
||||||
'jest-preset-angular/build/serializers/no-ng-attributes',
|
|
||||||
'jest-preset-angular/build/serializers/ng-snapshot',
|
|
||||||
'jest-preset-angular/build/serializers/html-comment',
|
|
||||||
],
|
|
||||||
testMatch: [
|
|
||||||
'<rootDir>/src/**/__tests__/**/*.[jt]s?(x)',
|
|
||||||
'<rootDir>/src/**/?(*.)+(spec|test).[jt]s?(x)',
|
|
||||||
],
|
|
||||||
};
|
|
@ -1,31 +0,0 @@
|
|||||||
const path = require('path');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
displayName: __dirname.split(path.sep).slice(-2).join(path.posix.sep),
|
|
||||||
preset: 'jest-preset-angular/presets/defaults-esm',
|
|
||||||
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
|
|
||||||
transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid)'],
|
|
||||||
snapshotFormat: {
|
|
||||||
escapeString: true,
|
|
||||||
printBasicPrototype: true,
|
|
||||||
},
|
|
||||||
coverageDirectory: './coverage/testapp',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.(ts|mjs|js|html)$': [
|
|
||||||
'jest-preset-angular',
|
|
||||||
{
|
|
||||||
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
||||||
stringifyContentPathRegex: '\\.(html|svg)$',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
snapshotSerializers: [
|
|
||||||
'jest-preset-angular/build/serializers/no-ng-attributes',
|
|
||||||
'jest-preset-angular/build/serializers/ng-snapshot',
|
|
||||||
'jest-preset-angular/build/serializers/html-comment',
|
|
||||||
],
|
|
||||||
testMatch: [
|
|
||||||
'<rootDir>/src/**/__tests__/**/*.[jt]s?(x)',
|
|
||||||
'<rootDir>/src/**/?(*.)+(spec|test).[jt]s?(x)',
|
|
||||||
],
|
|
||||||
};
|
|
@ -65,6 +65,7 @@
|
|||||||
"webpack": "5"
|
"webpack": "5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@analogjs/vite-plugin-angular": "^0.2.24",
|
||||||
"@angular-devkit/architect": "^0.1700.5",
|
"@angular-devkit/architect": "^0.1700.5",
|
||||||
"@angular-devkit/build-angular": "^17.0.5",
|
"@angular-devkit/build-angular": "^17.0.5",
|
||||||
"@angular-devkit/core": "^17.0.5",
|
"@angular-devkit/core": "^17.0.5",
|
||||||
@ -80,8 +81,7 @@
|
|||||||
"@types/cross-spawn": "^6.0.2",
|
"@types/cross-spawn": "^6.0.2",
|
||||||
"@types/tmp": "^0.2.3",
|
"@types/tmp": "^0.2.3",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"jest": "^29.7.0",
|
"jsdom": "^23.0.1",
|
||||||
"jest-preset-angular": "^13.0.1",
|
|
||||||
"tmp": "^0.2.1",
|
"tmp": "^0.2.1",
|
||||||
"typescript": "^5.3.2",
|
"typescript": "^5.3.2",
|
||||||
"webpack": "5",
|
"webpack": "5",
|
||||||
|
@ -3,7 +3,7 @@ import { vi, describe, afterEach, it, expect } from 'vitest';
|
|||||||
import { LoggerApi } from '@angular-devkit/core/src/logger';
|
import { LoggerApi } from '@angular-devkit/core/src/logger';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
|
|
||||||
const { runCompodoc } = require('./run-compodoc');
|
import { runCompodoc } from './run-compodoc';
|
||||||
|
|
||||||
const mockRunScript = vi.fn();
|
const mockRunScript = vi.fn();
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
import { extractType, setCompodocJson } from './compodoc';
|
import { extractType, setCompodocJson } from './compodoc';
|
||||||
import { CompodocJson, Decorator } from './types';
|
import { CompodocJson, Decorator } from './types';
|
||||||
|
|
||||||
|
10
code/frameworks/angular/src/test-setup.ts
Normal file
10
code/frameworks/angular/src/test-setup.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||||
|
import '@analogjs/vite-plugin-angular/setup-vitest';
|
||||||
|
|
||||||
|
import {
|
||||||
|
BrowserDynamicTestingModule,
|
||||||
|
platformBrowserDynamicTesting,
|
||||||
|
} from '@angular/platform-browser-dynamic/testing';
|
||||||
|
import { getTestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"extends": "./tsconfig.json",
|
"extends": "./tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"types": ["webpack-env", "jest", "node"],
|
"types": ["webpack-env", "node"],
|
||||||
"typeRoots": ["../../node_modules/@types", "node_modules/@types"],
|
"typeRoots": ["../../node_modules/@types", "node_modules/@types"],
|
||||||
"allowJs": true
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"include": ["**/*.test.ts", "**/*.d.ts", "setup-jest.ts"]
|
"include": ["**/*.test.ts", "**/*.d.ts"]
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
/* eslint-disable import/no-extraneous-dependencies */
|
/* eslint-disable import/no-extraneous-dependencies */
|
||||||
import { defineConfig, mergeConfig } from 'vitest/config';
|
import { defineConfig, mergeConfig } from 'vitest/config';
|
||||||
import { sep, posix } from 'path';
|
import { sep, posix } from 'path';
|
||||||
import { createVuePlugin } from 'vite-plugin-vue2';
|
|
||||||
import { vitestCommonConfig } from '../../vitest.workspace';
|
import { vitestCommonConfig } from '../../vitest.workspace';
|
||||||
|
|
||||||
export default mergeConfig(
|
export default defineConfig(({ mode }) => {
|
||||||
vitestCommonConfig,
|
return mergeConfig(vitestCommonConfig, {
|
||||||
defineConfig({
|
|
||||||
test: {
|
test: {
|
||||||
|
setupFiles: ['src/test-setup.ts'],
|
||||||
environment: 'jsdom',
|
environment: 'jsdom',
|
||||||
|
|
||||||
name: __dirname.split(sep).slice(-2).join(posix.sep),
|
name: __dirname.split(sep).slice(-2).join(posix.sep),
|
||||||
},
|
},
|
||||||
plugins: [createVuePlugin()],
|
});
|
||||||
})
|
});
|
||||||
);
|
|
||||||
|
936
code/yarn.lock
936
code/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user