From 89cee2b5ecca5053b70e2d8f24e1329c3fc39ca2 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 21 Feb 2022 18:34:08 +0100 Subject: [PATCH 1/4] update jest-preset-angular configs --- app/angular/setup-jest.ts | 2 +- examples/angular-cli/jest-config/setup.ts | 2 +- examples/angular-cli/jest.config.js | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/angular/setup-jest.ts b/app/angular/setup-jest.ts index 3e05aa930bb..3caa9164960 100644 --- a/app/angular/setup-jest.ts +++ b/app/angular/setup-jest.ts @@ -1,4 +1,4 @@ // eslint-disable-next-line import/no-extraneous-dependencies -import 'jest-preset-angular'; +import 'jest-preset-angular/setup-jest'; global.EventSource = class {} as any; diff --git a/examples/angular-cli/jest-config/setup.ts b/examples/angular-cli/jest-config/setup.ts index b3714757f35..276aba67d76 100644 --- a/examples/angular-cli/jest-config/setup.ts +++ b/examples/angular-cli/jest-config/setup.ts @@ -1,4 +1,4 @@ -import 'jest-preset-angular'; +import 'jest-preset-angular/setup-jest'; import './globalMocks'; require('@storybook/babel-plugin-require-context-hook/register')(); diff --git a/examples/angular-cli/jest.config.js b/examples/angular-cli/jest.config.js index 422ede7df83..d64bd077b51 100644 --- a/examples/angular-cli/jest.config.js +++ b/examples/angular-cli/jest.config.js @@ -7,7 +7,7 @@ module.exports = { preset: 'jest-preset-angular', globals: { 'ts-jest': { - tsConfig: path.join(__dirname, 'src/tsconfig.spec.json'), + tsconfig: path.join(__dirname, 'src/tsconfig.spec.json'), stringifyContentPathRegex: '\\.html$', astTransformers: { before: [ @@ -26,9 +26,9 @@ module.exports = { }, moduleFileExtensions: [...config.moduleFileExtensions, 'html'], snapshotSerializers: [ - 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js', - 'jest-preset-angular/build/AngularSnapshotSerializer.js', - 'jest-preset-angular/build/HTMLCommentSerializer.js', + 'jest-preset-angular/build/serializers/html-comment', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/no-ng-attributes', ], setupFilesAfterEnv: ['./jest-config/setup.ts'], testPathIgnorePatterns: ['app.component.spec.ts'], From a266d27356addff0609f3962dd9174039213e547 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Wed, 11 May 2022 14:12:50 +0200 Subject: [PATCH 2/4] chore: add baseUrl to mocked ng workspace tsconfigs --- .../with-lib/projects/pattern-lib/tsconfig.lib.json | 1 + .../projects/pattern-lib/tsconfig.lib.json | 1 + 2 files changed, 2 insertions(+) diff --git a/app/angular/src/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json b/app/angular/src/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json index 6e06ad542ed..557265aa5b5 100644 --- a/app/angular/src/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +++ b/app/angular/src/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json @@ -2,6 +2,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "baseUrl": ".", "outDir": "../../out-tsc/lib", "target": "es2015", "declaration": true, diff --git a/app/angular/src/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json b/app/angular/src/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json index 6e06ad542ed..557265aa5b5 100644 --- a/app/angular/src/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +++ b/app/angular/src/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json @@ -2,6 +2,7 @@ { "extends": "../../tsconfig.json", "compilerOptions": { + "baseUrl": ".", "outDir": "../../out-tsc/lib", "target": "es2015", "declaration": true, From 5452005302198b3151769e84645ee34a9b385b25 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Wed, 11 May 2022 14:36:04 +0200 Subject: [PATCH 3/4] cleanup error logs from angular test --- app/angular/src/builders/start-storybook/index.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/angular/src/builders/start-storybook/index.spec.ts b/app/angular/src/builders/start-storybook/index.spec.ts index 657087f4839..1430ea25e5b 100644 --- a/app/angular/src/builders/start-storybook/index.spec.ts +++ b/app/angular/src/builders/start-storybook/index.spec.ts @@ -124,7 +124,7 @@ describe('Start Storybook Builder', () => { }); it('should throw error', async () => { - buildStandaloneMock.mockRejectedValue(new Error()); + buildStandaloneMock.mockRejectedValue(true); const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', { browserTarget: 'angular-cli:build-2', From 71986620b04b7aea81529544a47982b0a4337bec Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Mon, 16 May 2022 12:44:24 +0200 Subject: [PATCH 4/4] supress unnecessary angular console logs from tests --- app/angular/src/builders/build-storybook/index.spec.ts | 2 +- .../src/client/preview/angular-beta/RendererFactory.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/angular/src/builders/build-storybook/index.spec.ts b/app/angular/src/builders/build-storybook/index.spec.ts index c396c9cc6d9..40b12a8b880 100644 --- a/app/angular/src/builders/build-storybook/index.spec.ts +++ b/app/angular/src/builders/build-storybook/index.spec.ts @@ -142,7 +142,7 @@ describe('Build Storybook Builder', () => { }); it('should throw error', async () => { - buildStandaloneMock.mockRejectedValue(new Error()); + buildStandaloneMock.mockRejectedValue(true); const run = await architect.scheduleBuilder('@storybook/angular:start-storybook', { browserTarget: 'angular-cli:build-2', diff --git a/app/angular/src/client/preview/angular-beta/RendererFactory.test.ts b/app/angular/src/client/preview/angular-beta/RendererFactory.test.ts index d9976268d77..3d57c6c9ef2 100644 --- a/app/angular/src/client/preview/angular-beta/RendererFactory.test.ts +++ b/app/angular/src/client/preview/angular-beta/RendererFactory.test.ts @@ -22,6 +22,7 @@ describe('RendererFactory', () => { rootTargetDOMNode = global.document.getElementById('root'); rootDocstargetDOMNode = global.document.getElementById('root-docs'); (platformBrowserDynamic as any).mockImplementation(platformBrowserDynamicTesting); + jest.spyOn(console, 'log').mockImplementation(() => {}); }); afterEach(() => {