Skip to content

Commit

Permalink
Merge pull request #18196 from storybookjs/chore/fix-angular-test-pre…
Browse files Browse the repository at this point in the history
…sets

Cleanup noise from unit tests
  • Loading branch information
yannbf committed May 16, 2022
2 parents fb4f6dc + 7198662 commit 3e2b7f1
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/angular/setup-jest.ts
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion app/angular/src/builders/build-storybook/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion app/angular/src/builders/start-storybook/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
Expand Down
2 changes: 1 addition & 1 deletion examples/angular-cli/jest-config/setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'jest-preset-angular';
import 'jest-preset-angular/setup-jest';
import './globalMocks';

require('@storybook/babel-plugin-require-context-hook/register')();
8 changes: 4 additions & 4 deletions examples/angular-cli/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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'],
Expand Down

0 comments on commit 3e2b7f1

Please sign in to comment.