diff --git a/e2e/__tests__/calc/calc.component.ts b/e2e/__tests__/calc/calc.component.ts index ecca06d89c..ca029c9e3e 100644 --- a/e2e/__tests__/calc/calc.component.ts +++ b/e2e/__tests__/calc/calc.component.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core'; -import * as image from 'e2e/test-app-v10/src/assets/its_something.png'; + +import image from './its_something.png'; @Component({ selector: 'app-calc', diff --git a/e2e/__tests__/calc/its_something.png b/e2e/__tests__/calc/its_something.png new file mode 100644 index 0000000000..9f046efe98 Binary files /dev/null and b/e2e/__tests__/calc/its_something.png differ diff --git a/e2e/__tests__/forward-ref/forward-ref.spec.ts b/e2e/__tests__/forward-ref/forward-ref.spec.ts index 984fe59a33..da5681b5af 100644 --- a/e2e/__tests__/forward-ref/forward-ref.spec.ts +++ b/e2e/__tests__/forward-ref/forward-ref.spec.ts @@ -1,12 +1,10 @@ import { forwardRef, Inject, Injector } from '@angular/core'; -const shouldSkipTest = process.env.NG_VERSION === 'v9' || process.env.ISOLATED_MODULES === 'true'; +const shouldSkipTest = process.env.ISOLATED_MODULES === 'true'; const skipTest = shouldSkipTest ? test.skip : test; if (shouldSkipTest) { - process.stdout.write( - '\nforwardRef only works in non-isolatedModules mode with ES2015 in Angular 10+, with Angular 9 requires ES5\n', - ); + process.stdout.write('\nforwardRef only works in non-isolatedModules mode\n'); } skipTest('forwardRef should work', () => { diff --git a/e2e/__tests__/heroes/hero.service.spec.ts b/e2e/__tests__/heroes/hero.service.spec.ts index b58d09a00d..70d6fb8531 100644 --- a/e2e/__tests__/heroes/hero.service.spec.ts +++ b/e2e/__tests__/heroes/hero.service.spec.ts @@ -1,6 +1,7 @@ import { HttpClientModule, HttpErrorResponse, HttpRequest } from '@angular/common/http'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { jest } from '@jest/globals'; import { heroesUrl, HeroService } from './hero.service'; diff --git a/e2e/__tests__/heroes/heroes.component.spec.ts b/e2e/__tests__/heroes/heroes.component.spec.ts index 1b3192f8ef..02ec41e43b 100644 --- a/e2e/__tests__/heroes/heroes.component.spec.ts +++ b/e2e/__tests__/heroes/heroes.component.spec.ts @@ -1,4 +1,5 @@ import { async, ComponentFixture } from '@angular/core/testing'; +import { jest } from '@jest/globals'; import { Subject } from 'rxjs'; import { ConfigureFn, configureTests } from '../__helpers__'; diff --git a/e2e/test-app-v10/jest-esm-iso.config.js b/e2e/test-app-v10/jest-esm-iso.config.js index d29930b6e2..98289d0076 100644 --- a/e2e/test-app-v10/jest-esm-iso.config.js +++ b/e2e/test-app-v10/jest-esm-iso.config.js @@ -4,6 +4,7 @@ const baseConfig = require('./jest.config'); /** @type {import('ts-jest/dist/types').ProjectConfigTsJest} */ module.exports = { ...baseConfig, + extensionsToTreatAsEsm: ['.ts'], globals: { 'ts-jest': { tsconfig: '/tsconfig-esm.spec.json', @@ -12,4 +13,9 @@ module.exports = { isolatedModules: true, } }, + moduleNameMapper: { + ...baseConfig.moduleNameMapper, + 'tslib': '/node_modules/tslib/tslib.es6.js', + }, + transformIgnorePatterns: ['node_modules/(?!tslib)'], }; diff --git a/e2e/test-app-v10/package.json b/e2e/test-app-v10/package.json index aed7c60244..a4f19d5ab6 100644 --- a/e2e/test-app-v10/package.json +++ b/e2e/test-app-v10/package.json @@ -5,8 +5,9 @@ "ng": "ng", "start": "ng serve", "build": "ng build", - "test-cjs-uniso": "jest --clearCache && jest -c=jest-cjs-uniso.config.js -u", + "test-cjs-uniso": "jest --clearCache && jest -c=jest-cjs-uniso.config.js", "test-cjs-iso": "jest --clearCache && jest -c=jest-cjs-iso.config.js", + "test-esm-iso": "jest --clearCache && node --experimental-vm-modules ./node_modules/jest/bin/jest.js -c=jest-esm-iso.config.js", "lint": "ng lint" }, "private": true, @@ -37,4 +38,4 @@ "ts-node": "^9.1.1", "typescript": "~4.0.5" } -} \ No newline at end of file +} diff --git a/e2e/test-app-v10/tsconfig-esm.spec.json b/e2e/test-app-v10/tsconfig-esm.spec.json index 22c1218935..5583ce3450 100644 --- a/e2e/test-app-v10/tsconfig-esm.spec.json +++ b/e2e/test-app-v10/tsconfig-esm.spec.json @@ -2,7 +2,6 @@ { "extends": "./tsconfig.spec.json", "compilerOptions": { - "module": "ESNext", - "esModuleInterop": true + "module": "ESNext" }, } diff --git a/e2e/test-app-v10/tsconfig.spec.json b/e2e/test-app-v10/tsconfig.spec.json index 94aacaaded..770989bc88 100644 --- a/e2e/test-app-v10/tsconfig.spec.json +++ b/e2e/test-app-v10/tsconfig.spec.json @@ -8,7 +8,9 @@ "jquery", "node" ], - "allowJs": true + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true }, "files": [ "src/global.ts" diff --git a/e2e/test-app-v11/jest-esm-iso.config.js b/e2e/test-app-v11/jest-esm-iso.config.js index d29930b6e2..98289d0076 100644 --- a/e2e/test-app-v11/jest-esm-iso.config.js +++ b/e2e/test-app-v11/jest-esm-iso.config.js @@ -4,6 +4,7 @@ const baseConfig = require('./jest.config'); /** @type {import('ts-jest/dist/types').ProjectConfigTsJest} */ module.exports = { ...baseConfig, + extensionsToTreatAsEsm: ['.ts'], globals: { 'ts-jest': { tsconfig: '/tsconfig-esm.spec.json', @@ -12,4 +13,9 @@ module.exports = { isolatedModules: true, } }, + moduleNameMapper: { + ...baseConfig.moduleNameMapper, + 'tslib': '/node_modules/tslib/tslib.es6.js', + }, + transformIgnorePatterns: ['node_modules/(?!tslib)'], }; diff --git a/e2e/test-app-v11/package.json b/e2e/test-app-v11/package.json index 8a637fcc51..d198c88577 100644 --- a/e2e/test-app-v11/package.json +++ b/e2e/test-app-v11/package.json @@ -7,6 +7,7 @@ "build": "ng build", "test-cjs-uniso": "jest --clearCache && jest -c=jest-cjs-uniso.config.js", "test-cjs-iso": "jest --clearCache && jest -c=jest-cjs-iso.config.js", + "test-esm-iso": "jest --clearCache && node --experimental-vm-modules ./node_modules/jest/bin/jest.js -c=jest-esm-iso.config.js", "lint": "ng lint" }, "private": true, @@ -37,4 +38,4 @@ "ts-node": "^9.1.1", "typescript": "~4.0.5" } -} \ No newline at end of file +} diff --git a/e2e/test-app-v11/tsconfig-esm.spec.json b/e2e/test-app-v11/tsconfig-esm.spec.json index 22c1218935..5583ce3450 100644 --- a/e2e/test-app-v11/tsconfig-esm.spec.json +++ b/e2e/test-app-v11/tsconfig-esm.spec.json @@ -2,7 +2,6 @@ { "extends": "./tsconfig.spec.json", "compilerOptions": { - "module": "ESNext", - "esModuleInterop": true + "module": "ESNext" }, } diff --git a/e2e/test-app-v11/tsconfig.spec.json b/e2e/test-app-v11/tsconfig.spec.json index 94aacaaded..770989bc88 100644 --- a/e2e/test-app-v11/tsconfig.spec.json +++ b/e2e/test-app-v11/tsconfig.spec.json @@ -8,7 +8,9 @@ "jquery", "node" ], - "allowJs": true + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true }, "files": [ "src/global.ts" diff --git a/e2e/test-app-v9/jest-esm-iso.config.js b/e2e/test-app-v9/jest-esm-iso.config.js index d29930b6e2..98289d0076 100644 --- a/e2e/test-app-v9/jest-esm-iso.config.js +++ b/e2e/test-app-v9/jest-esm-iso.config.js @@ -4,6 +4,7 @@ const baseConfig = require('./jest.config'); /** @type {import('ts-jest/dist/types').ProjectConfigTsJest} */ module.exports = { ...baseConfig, + extensionsToTreatAsEsm: ['.ts'], globals: { 'ts-jest': { tsconfig: '/tsconfig-esm.spec.json', @@ -12,4 +13,9 @@ module.exports = { isolatedModules: true, } }, + moduleNameMapper: { + ...baseConfig.moduleNameMapper, + 'tslib': '/node_modules/tslib/tslib.es6.js', + }, + transformIgnorePatterns: ['node_modules/(?!tslib)'], }; diff --git a/e2e/test-app-v9/package.json b/e2e/test-app-v9/package.json index 5ed61ffb63..a68d09d47c 100644 --- a/e2e/test-app-v9/package.json +++ b/e2e/test-app-v9/package.json @@ -7,6 +7,7 @@ "build": "ng build", "test-cjs-uniso": "jest --clearCache && jest -c=jest-cjs-uniso.config.js", "test-cjs-iso": "jest --clearCache && jest -c=jest-cjs-iso.config.js", + "test-esm-iso": "jest --clearCache && node --experimental-vm-modules ./node_modules/jest/bin/jest.js -c=jest-esm-iso.config.js", "lint": "ng lint" }, "private": true, @@ -37,4 +38,4 @@ "ts-node": "^9.1.1", "typescript": "~3.8.3" } -} \ No newline at end of file +} diff --git a/e2e/test-app-v9/tsconfig-esm.spec.json b/e2e/test-app-v9/tsconfig-esm.spec.json index 22c1218935..5583ce3450 100644 --- a/e2e/test-app-v9/tsconfig-esm.spec.json +++ b/e2e/test-app-v9/tsconfig-esm.spec.json @@ -2,7 +2,6 @@ { "extends": "./tsconfig.spec.json", "compilerOptions": { - "module": "ESNext", - "esModuleInterop": true + "module": "ESNext" }, } diff --git a/e2e/test-app-v9/tsconfig.spec.json b/e2e/test-app-v9/tsconfig.spec.json index 94aacaaded..770989bc88 100644 --- a/e2e/test-app-v9/tsconfig.spec.json +++ b/e2e/test-app-v9/tsconfig.spec.json @@ -8,7 +8,9 @@ "jquery", "node" ], - "allowJs": true + "allowJs": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true }, "files": [ "src/global.ts" diff --git a/scripts/e2e.js b/scripts/e2e.js index 579f5ca10a..46a0abe0cc 100755 --- a/scripts/e2e.js +++ b/scripts/e2e.js @@ -24,11 +24,6 @@ const executeTest = (projectRealPath) => { logger.log('='.repeat(20), `${projectPkg.name}@${projectPkg.version}`, 'in', projectRealPath, '='.repeat(20)); logger.log(); - logger.log('setting NG_VERSION environment variable'); - logger.log(); - const projectName = projectRealPath.match(/([^\\/]*)\/*$/)[1]; - process.env.NG_VERSION = projectName.substring(projectName.lastIndexOf('-') + 1); - // then we install it in the repo logger.log('ensuring all dependencies of target project are installed'); logger.log(); @@ -61,14 +56,14 @@ const executeTest = (projectRealPath) => { // then we can run the tests const cmdCjsUnIso = ['yarn', 'test-cjs-uniso']; const cmdCjsIso = ['yarn', 'test-cjs-iso']; - // const cmdESMIso = ['yarn', 'test-esm-iso']; + const cmdESMIso = ['yarn', 'test-esm-iso']; if (jestArgs.length) { cmdCjsUnIso.push('--'); cmdCjsIso.push('--'); - // cmdESMIso.push('--'); + cmdESMIso.push('--'); cmdCjsUnIso.push(...jestArgs); cmdCjsIso.push(...jestArgs); - // cmdESMIso.push(...jestArgs); + cmdESMIso.push(...jestArgs); } logger.log('STARTING NONE ISOLATED MODULES TESTS'); @@ -98,19 +93,20 @@ const executeTest = (projectRealPath) => { env: process.env, }); - // logger.log('starting the ESM tests using:', ...cmdCjsIso); - // logger.log(); - // - // execa.sync(cmdESMIso.shift(), cmdESMIso, { - // cwd: projectRealPath, - // stdio: 'inherit', - // env: process.env, - // }); + logger.log(); + logger.log('starting the ESM tests using:', ...cmdESMIso); + logger.log(); + + execa.sync(cmdESMIso.shift(), cmdESMIso, { + cwd: projectRealPath, + stdio: 'inherit', + env: process.env, + }); + logger.log(); logger.log('cleaning up'); execa.sync('rimraf', [testCasesDest]); - delete process.env.NG_VERSION; delete process.env.ISOLATED_MODULES; };