jest-preset-angular
Advanced tools
Comparing version 14.1.0 to 14.1.1
@@ -14,3 +14,3 @@ "use strict"; | ||
} | ||
_transpileOutput(fileContent, fileName) { | ||
_transpileOutput(fileContent, filePath) { | ||
const diagnostics = []; | ||
@@ -33,3 +33,3 @@ const compilerOptions = Object.assign({}, this._compilerOptions); | ||
options.allowNonTsExtensions = true; | ||
const inputFileName = fileName || (compilerOptions && compilerOptions.jsx ? 'module.tsx' : 'module.ts'); | ||
const inputFileName = filePath || (compilerOptions && compilerOptions.jsx ? 'module.tsx' : 'module.ts'); | ||
const sourceFile = this._ts.createSourceFile(inputFileName, fileContent, options.target); | ||
@@ -40,3 +40,3 @@ const newLine = this._ts.getNewLineCharacter(options); | ||
const compilerHost = { | ||
getSourceFile: (fileName) => (fileName === this._ts.normalizePath(inputFileName) ? sourceFile : undefined), | ||
getSourceFile: (fileName) => fileName === this._ts.normalizePath(inputFileName) ? sourceFile : undefined, | ||
writeFile: (name, text) => { | ||
@@ -68,4 +68,5 @@ if (this._ts.fileExtensionIs(name, '.map')) { | ||
this.program.emit(undefined, undefined, undefined, undefined, this._makeTransformers(this.configSet.resolvedTransformers)); | ||
if (outputText === undefined) | ||
if (outputText === undefined) { | ||
return this._ts.Debug.fail('Output generation failed'); | ||
} | ||
return { outputText, diagnostics, sourceMapText }; | ||
@@ -72,0 +73,0 @@ } |
"use strict"; | ||
const attributesToRemovePatterns = ['__ngContext__']; | ||
const print = (fixture, print, indent, opts, colors) => { | ||
const print = (fixture, printer, indent, opts, colors) => { | ||
let componentAttrs = ''; | ||
@@ -8,3 +8,3 @@ const { componentRef, componentInstance } = fixture; | ||
const componentName = componentDef.selectors[0][0]; | ||
const nodes = Array.from(componentRef.location.nativeElement.childNodes).map(print).join(''); | ||
const nodes = Array.from(componentRef.location.nativeElement.childNodes).map(printer).join(''); | ||
const attributes = Object.keys(componentInstance).filter((key) => !attributesToRemovePatterns.includes(key)); | ||
@@ -11,0 +11,0 @@ if (attributes.length) { |
@@ -91,5 +91,5 @@ "use strict"; | ||
const styleReplacements = []; | ||
let properties = typescript_1.default.visitNodes(objectExpression.properties, (node) => typescript_1.default.isObjectLiteralElementLike(node) | ||
? visitComponentMetadata(nodeFactory, node, resourceImportDeclarations, moduleKind) | ||
: node); | ||
let properties = typescript_1.default.visitNodes(objectExpression.properties, (objExpressionNode) => typescript_1.default.isObjectLiteralElementLike(objExpressionNode) | ||
? visitComponentMetadata(nodeFactory, objExpressionNode, resourceImportDeclarations, moduleKind) | ||
: objExpressionNode); | ||
if (styleReplacements.length) { | ||
@@ -96,0 +96,0 @@ const styleProperty = nodeFactory.createPropertyAssignment(nodeFactory.createIdentifier(constants_1.STYLES), nodeFactory.createArrayLiteralExpression(styleReplacements)); |
@@ -28,3 +28,4 @@ "use strict"; | ||
const packagePath = require.resolve(ANGULAR_COMPILER_CLI_PKG_NAME); | ||
const substringLength = packagePath.indexOf(ANGULAR_COMPILER_CLI_PKG_NAME.replace('/', path_1.default.sep)) + ANGULAR_COMPILER_CLI_PKG_NAME.length; | ||
const substringLength = packagePath.indexOf(ANGULAR_COMPILER_CLI_PKG_NAME.replace('/', path_1.default.sep)) + | ||
ANGULAR_COMPILER_CLI_PKG_NAME.length; | ||
const ngCompilerCliFolder = packagePath.substring(0, substringLength); | ||
@@ -31,0 +32,0 @@ const ngCompilerCliPackageJson = `${ngCompilerCliFolder}/package.json`; |
@@ -0,1 +1,9 @@ | ||
## [14.1.1](https://github.com/thymikee/jest-preset-angular/compare/v14.1.0...v14.1.1) (2024-06-19) | ||
### Features | ||
* feat: add polyfill for TextEncoder ([c0af6c3](https://github.com/thymikee/jest-preset-angular/commit/c0af6c3)), closes [#1914](https://github.com/thymikee/jest-preset-angular/issues/1914) [#2514](https://github.com/thymikee/jest-preset-angular/issues/2514) | ||
# [14.1.0](https://github.com/thymikee/jest-preset-angular/compare/v14.0.4...v14.1.0) (2024-05-21) | ||
@@ -297,3 +305,3 @@ | ||
* Since **Angular 11**, the minimum version of `zone.js` is **0.11.x** and Angular 10 is EOL, so now we can use zone patch directly from `zone.js`. | ||
* Since **Angular 11**, the minimum version of `zone.js` is **0.11.x** and Angular 10 is EOL, so now we can use zone patch directly from `zone.js`. | ||
If one is not using `zone.js@0.11.x`, please upgrade. | ||
@@ -303,4 +311,4 @@ * Now we are using Angular AST transformers, `reflect-metadata` is not needed anymore. | ||
* **Node 12** is no longer support | ||
* Previously, we always checked file extension `.mjs` and any files from `node_modules` excluding `tslib` to be processed with `esbuild`. | ||
With the new option `processWithEsbuild`, now we put default all `.mjs` files to be processed by `esbuild`. Files like `lodash-es` default isn't processed by `esbuild`. | ||
* Previously, we always checked file extension `.mjs` and any files from `node_modules` excluding `tslib` to be processed with `esbuild`. | ||
With the new option `processWithEsbuild`, now we put default all `.mjs` files to be processed by `esbuild`. Files like `lodash-es` default isn't processed by `esbuild`. | ||
If you wish to use `esbuild` to process such files, please configure in your Jest config like | ||
@@ -464,3 +472,3 @@ ``` | ||
* **NodeJs** range version support now is `^12.20.0 || ^14.15.0 || >=16.10.0` | ||
* Due to the introduction of **ESM package format** for Angular packages, several things are added to the **default preset** | ||
* Due to the introduction of **ESM package format** for Angular packages, several things are added to the **default preset** | ||
to handle `.mjs` files from **Angular ESM packages**. Please check our migration documentation at https://thymikee.github.io/jest-preset-angular/docs/next/guides/angular-13+ | ||
@@ -650,3 +658,3 @@ | ||
Ones who are relying on the value of `moduleNameMapper` from the preset should create their own `moduleNameMapper` | ||
config manually or via `ts-jest` util https://kulshekhar.github.io/ts-jest/docs/getting-started/paths-mapping. | ||
config manually or via `ts-jest` util https://kulshekhar.github.io/ts-jest/docs/getting-started/paths-mapping. | ||
@@ -653,0 +661,0 @@ If you wish to reuse the old configuration of `moduleNameMapper`, you can put this into your Jest config |
{ | ||
"name": "jest-preset-angular", | ||
"version": "14.1.0", | ||
"version": "14.1.1", | ||
"description": "Jest preset configuration for Angular projects", | ||
@@ -32,4 +32,4 @@ "license": "MIT", | ||
"build": "tsc -p tsconfig.build.json && yarn build-transformers-bundle", | ||
"lint": "eslint --ext .js,.ts .", | ||
"lint-fix": "eslint --fix --ext .js,.ts .", | ||
"lint": "eslint .", | ||
"lint-fix": "eslint --fix .", | ||
"lint-prettier": "prettier \"**/*.{yml,yaml,md}\" --write", | ||
@@ -67,10 +67,13 @@ "lint-prettier-ci": "prettier \"**/*.{yml,yaml,md}\" --check", | ||
"devDependencies": { | ||
"@angular-devkit/build-angular": "^17.3.7", | ||
"@angular/animations": "^17.3.9", | ||
"@angular/common": "^17.3.9", | ||
"@angular/compiler": "^17.3.9", | ||
"@angular/compiler-cli": "^17.3.9", | ||
"@angular/core": "^17.3.9", | ||
"@angular/platform-browser": "^17.3.9", | ||
"@angular/platform-browser-dynamic": "^17.3.9", | ||
"@angular-devkit/build-angular": "^18.0.4", | ||
"@angular-eslint/eslint-plugin": "^17.5.2", | ||
"@angular-eslint/eslint-plugin-template": "^17.5.2", | ||
"@angular-eslint/template-parser": "^17.5.2", | ||
"@angular/animations": "^18.0.3", | ||
"@angular/common": "^18.0.3", | ||
"@angular/compiler": "^18.0.3", | ||
"@angular/compiler-cli": "^18.0.3", | ||
"@angular/core": "^18.0.3", | ||
"@angular/platform-browser": "^18.0.3", | ||
"@angular/platform-browser-dynamic": "^18.0.3", | ||
"@commitlint/cli": "^19.3.0", | ||
@@ -81,6 +84,6 @@ "@commitlint/config-angular": "^19.3.0", | ||
"@types/jest": "^29.5.12", | ||
"@types/node": "^20.12.12", | ||
"@types/node": "^20.14.6", | ||
"@types/semver": "^7.5.8", | ||
"@typescript-eslint/eslint-plugin": "^7.10.0", | ||
"@typescript-eslint/parser": "^7.10.0", | ||
"@typescript-eslint/eslint-plugin": "^7.13.1", | ||
"@typescript-eslint/parser": "^7.13.1", | ||
"chalk": "^4.1.2", | ||
@@ -92,5 +95,4 @@ "conventional-changelog-cli": "^5.0.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jest": "^28.5.0", | ||
"eslint-plugin-jsdoc": "^48.2.5", | ||
"eslint-plugin-prefer-arrow": "^1.2.3", | ||
"eslint-plugin-jest": "^28.6.0", | ||
"eslint-plugin-jsdoc": "^48.2.12", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
@@ -100,15 +102,15 @@ "execa": "5.1.1", | ||
"github-files-fetcher": "^1.6.0", | ||
"glob": "^10.3.15", | ||
"glob": "^10.4.2", | ||
"husky": "^9.0.11", | ||
"jest": "^29.7.0", | ||
"pinst": "^3.0.0", | ||
"prettier": "^3.2.5", | ||
"prettier": "^3.3.2", | ||
"rimraf": "^5.0.7", | ||
"rxjs": "^7.8.1", | ||
"ts-node": "^10.9.2", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.0 <5.3.0", | ||
"zone.js": "~0.14.6" | ||
"tslib": "^2.6.3", | ||
"typescript": "^5.4.0 <5.5.0", | ||
"zone.js": "~0.14.7" | ||
}, | ||
"packageManager": "yarn@4.2.2" | ||
"packageManager": "yarn@4.3.0" | ||
} |
declare const _default: { | ||
defaults: { | ||
transformIgnorePatterns: string[]; | ||
transform: import('ts-jest').JestConfigWithTsJest['transform']; | ||
testEnvironment: string; | ||
moduleFileExtensions: string[]; | ||
snapshotSerializers: string[]; | ||
}; | ||
defaultsESM: { | ||
extensionsToTreatAsEsm: string[]; | ||
moduleNameMapper: { | ||
tslib: string; | ||
defaults: { | ||
transformIgnorePatterns: string[]; | ||
transform: import('ts-jest').JestConfigWithTsJest['transform']; | ||
testEnvironment: string; | ||
moduleFileExtensions: string[]; | ||
snapshotSerializers: string[]; | ||
}; | ||
transform: import('ts-jest').JestConfigWithTsJest['transform']; | ||
transformIgnorePatterns: string[]; | ||
testEnvironment: string; | ||
moduleFileExtensions: string[]; | ||
snapshotSerializers: string[]; | ||
}; | ||
defaultTransformerOptions: import('ts-jest').TsJestTransformerOptions; | ||
defaultsESM: { | ||
extensionsToTreatAsEsm: string[]; | ||
moduleNameMapper: { | ||
tslib: string; | ||
}; | ||
transform: import('ts-jest').JestConfigWithTsJest['transform']; | ||
transformIgnorePatterns: string[]; | ||
testEnvironment: string; | ||
moduleFileExtensions: string[]; | ||
snapshotSerializers: string[]; | ||
}; | ||
defaultTransformerOptions: import('ts-jest').TsJestTransformerOptions; | ||
}; | ||
export default _default; |
const ngJestPresets = require('../build/presets'); | ||
module.exports = { | ||
defaults: ngJestPresets.defaultPreset, | ||
defaultsESM: ngJestPresets.defaultEsmPreset, | ||
defaultTransformerOptions: ngJestPresets.defaultTransformerOptions, | ||
defaults: ngJestPresets.defaultPreset, | ||
defaultsESM: ngJestPresets.defaultEsmPreset, | ||
defaultTransformerOptions: ngJestPresets.defaultTransformerOptions, | ||
}; |
require('zone.js'); | ||
require('zone.js/testing'); | ||
const { TextEncoder, TextDecoder } = require('util'); | ||
const { getTestBed } = require('@angular/core/testing'); | ||
const { | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting, | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting, | ||
} = require('@angular/platform-browser-dynamic/testing'); | ||
if (typeof globalThis.TextEncoder === 'undefined') { | ||
globalThis.TextEncoder = TextEncoder; | ||
globalThis.TextDecoder = TextDecoder; | ||
} | ||
const testEnvironmentOptions = globalThis.ngJest?.testEnvironmentOptions ?? Object.create(null); | ||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), testEnvironmentOptions); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30
676257
43
3000