Skip to content

Commit

Permalink
cleanup(angular): remove unneeded stubbing for performance.mark in je…
Browse files Browse the repository at this point in the history
…st setup file
  • Loading branch information
leosvelperez committed Nov 8, 2023
1 parent 76306f0 commit fb0f0cc
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 398 deletions.
9 changes: 0 additions & 9 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,15 +297,6 @@
"description": "Rename 'browserTarget' to 'buildTarget'.",
"factory": "./src/migrations/update-17-1-0/browser-target-to-build-target"
},
"stub-performance-mark-in-jest-test-setup": {
"cli": "nx",
"version": "17.1.0-beta.3",
"requires": {
"@angular/core": ">=17.0.0-rc.3"
},
"description": "Stubs out 'performance.mark' in the Jest test setup file.",
"factory": "./src/migrations/update-17-1-0/stub-performance-mark-in-jest-test-setup"
},
"replace-nguniversal-builders": {
"cli": "nx",
"version": "17.1.0-beta.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Tree, joinPathFragments } from '@nx/devkit';
import { configurationGenerator } from '@nx/jest';
import { UnitTestRunner } from '../../../utils/test-runners';
import { getInstalledAngularVersionInfo } from '../../utils/version-utils';
import type { NormalizedSchema } from './normalized-schema';

export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) {
Expand All @@ -19,7 +18,6 @@ export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) {
'src',
'test-setup.ts'
);
const { major: angularMajorVersion } = getInstalledAngularVersionInfo(host);
if (options.strict && host.exists(setupFile)) {
const contents = host.read(setupFile, 'utf-8');
host.write(
Expand All @@ -31,17 +29,7 @@ globalThis.ngJest = {
errorOnUnknownProperties: true,
},
};
${contents}${
angularMajorVersion >= 17
? `
/**
* Angular uses performance.mark() which is not supported by jsdom. Stub it out
* to avoid errors.
*/
global.performance.mark = jest.fn();
`
: ''
}`
${contents}`
);
}
}
Expand Down
14 changes: 1 addition & 13 deletions packages/angular/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import addLintingGenerator from '../add-linting/add-linting';
import setupTailwindGenerator from '../setup-tailwind/setup-tailwind';
import {
addDependenciesToPackageJsonIfDontExist,
getInstalledAngularVersionInfo,
versions,
} from '../utils/version-utils';
import { addBuildableLibrariesPostCssDependencies } from '../utils/dependencies';
Expand Down Expand Up @@ -141,7 +140,6 @@ async function addUnitTestRunner(
'src',
'test-setup.ts'
);
const { major: angularMajorVersion } = getInstalledAngularVersionInfo(host);
if (options.strict && host.exists(setupFile)) {
const contents = host.read(setupFile, 'utf-8');
host.write(
Expand All @@ -153,17 +151,7 @@ globalThis.ngJest = {
errorOnUnknownProperties: true,
},
};
${contents}${
angularMajorVersion >= 17
? `
/**
* Angular uses performance.mark() which is not supported by jsdom. Stub it out
* to avoid errors.
*/
global.performance.mark = jest.fn();
`
: ''
}`
${contents}`
);
}
}
Expand Down

This file was deleted.

Loading

0 comments on commit fb0f0cc

Please sign in to comment.