From 55d4d252d2629f2dc0f9ec393aff2c72ebd860bf Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Sat, 13 Dec 2025 19:03:30 +0100 Subject: [PATCH] build: migrate to Angular workspace --- .gitignore | 2 - angular.json | 194 ++++++++++++++++++ apps/example-app-karma/project.json | 68 ------ apps/example-app/jest.config.ts | 27 ++- apps/example-app/project.json | 75 ------- apps/example-app/src/test-setup.ts | 3 - jest.config.ts | 7 +- jest.preset.js | 34 --- nx.json | 107 ---------- package.json | 36 +--- .../jest-utils/tests/create-mock.spec.ts | 2 +- projects/testing-library/jest.config.ts | 27 ++- projects/testing-library/project.json | 54 ----- .../dtl-as-dev-dependency/index.spec.ts | 8 +- projects/testing-library/test-setup.ts | 3 - .../tests/issues/issue-318.spec.ts | 2 +- tsconfig.json | 29 +++ tsconfig.spec.json | 8 + 18 files changed, 297 insertions(+), 389 deletions(-) create mode 100644 angular.json delete mode 100644 apps/example-app-karma/project.json delete mode 100644 apps/example-app/project.json delete mode 100644 jest.preset.js delete mode 100644 nx.json delete mode 100644 projects/testing-library/project.json create mode 100644 tsconfig.json create mode 100644 tsconfig.spec.json diff --git a/.gitignore b/.gitignore index 22faaca..2da4091 100644 --- a/.gitignore +++ b/.gitignore @@ -28,8 +28,6 @@ # misc /.angular/cache .angular -.nx -migrations.json .cache /.sass-cache /connect.lock diff --git a/angular.json b/angular.json new file mode 100644 index 0000000..ae48899 --- /dev/null +++ b/angular.json @@ -0,0 +1,194 @@ +{ + "$schema": "./node_modules/@angular/cli/lib/config/schema.json", + "version": 1, + "cli": { + "analytics": false, + "cache": { + "enabled": true, + "path": "./.cache/angular", + "environment": "all" + } + }, + "newProjectRoot": "projects", + "projects": { + "testing-library": { + "projectType": "library", + "root": "projects/testing-library", + "sourceRoot": "projects/testing-library/src", + "prefix": "lib", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:ng-packagr", + "options": { + "project": "projects/testing-library/ng-package.json" + }, + "configurations": { + "production": { + "tsConfig": "projects/testing-library/tsconfig.lib.prod.json" + }, + "development": { + "tsConfig": "projects/testing-library/tsconfig.lib.json" + } + }, + "defaultConfiguration": "production" + }, + "test": { + "builder": "@angular-builders/jest:run", + "options": { + "configPath": "projects/testing-library/jest.config.ts" + } + }, + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": ["projects/testing-library/**/*.ts", "projects/testing-library/**/*.html"] + } + } + } + }, + "example-app": { + "projectType": "application", + "root": "apps/example-app", + "sourceRoot": "apps/example-app/src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/apps/example-app", + "index": "apps/example-app/src/index.html", + "main": "apps/example-app/src/main.ts", + "polyfills": "apps/example-app/src/polyfills.ts", + "tsConfig": "apps/example-app/tsconfig.app.json", + "assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"], + "styles": ["apps/example-app/src/styles.css"], + "scripts": [] + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" + } + ], + "outputHashing": "all" + }, + "development": { + "buildOptimizer": false, + "optimization": false, + "vendorChunk": true, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "configurations": { + "production": { + "buildTarget": "example-app:build:production" + }, + "development": { + "buildTarget": "example-app:build:development" + } + }, + "defaultConfiguration": "development" + }, + "extract-i18n": { + "builder": "@angular-devkit/build-angular:extract-i18n", + "options": { + "buildTarget": "example-app:build" + } + }, + "test": { + "builder": "@angular-builders/jest:run", + "options": { + "configPath": "apps/example-app/jest.config.ts" + } + }, + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": ["apps/example-app/**/*.ts", "apps/example-app/**/*.html"] + } + } + } + }, + "example-app-karma": { + "projectType": "application", + "root": "apps/example-app-karma", + "sourceRoot": "apps/example-app-karma/src", + "prefix": "app", + "architect": { + "build": { + "builder": "@angular-devkit/build-angular:browser", + "options": { + "outputPath": "dist/apps/example-app-karma", + "index": "apps/example-app-karma/src/index.html", + "main": "apps/example-app-karma/src/main.ts", + "tsConfig": "apps/example-app-karma/tsconfig.app.json", + "assets": ["apps/example-app-karma/src/favicon.ico", "apps/example-app-karma/src/assets"], + "styles": [], + "scripts": [] + }, + "configurations": { + "production": { + "budgets": [ + { + "type": "anyComponentStyle", + "maximumWarning": "6kb" + } + ], + "outputHashing": "all" + }, + "development": { + "buildOptimizer": false, + "optimization": false, + "vendorChunk": true, + "extractLicenses": false, + "sourceMap": true, + "namedChunks": true + } + }, + "defaultConfiguration": "production" + }, + "serve": { + "builder": "@angular-devkit/build-angular:dev-server", + "configurations": { + "production": { + "buildTarget": "example-app-karma:build:production" + }, + "development": { + "buildTarget": "example-app-karma:build:development" + } + }, + "defaultConfiguration": "development" + }, + "test": { + "builder": "@angular-devkit/build-angular:karma", + "options": { + "main": "apps/example-app-karma/src/test.ts", + "tsConfig": "apps/example-app-karma/tsconfig.spec.json", + "karmaConfig": "apps/example-app-karma/karma.conf.js" + } + }, + "lint": { + "builder": "@angular-eslint/builder:lint", + "options": { + "lintFilePatterns": ["apps/example-app-karma/**/*.ts", "apps/example-app-karma/**/*.html"] + } + } + } + } + }, + "schematics": { + "@schematics/angular:component": { + "style": "scss", + "displayBlock": true, + "changeDetection": "OnPush" + } + } +} diff --git a/apps/example-app-karma/project.json b/apps/example-app-karma/project.json deleted file mode 100644 index 27c4cbd..0000000 --- a/apps/example-app-karma/project.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "example-app-karma", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "projectType": "application", - "sourceRoot": "apps/example-app-karma/src", - "prefix": "app", - "tags": [], - "generators": {}, - "targets": { - "build": { - "executor": "@angular-devkit/build-angular:browser", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/apps/example-app-karma", - "index": "apps/example-app-karma/src/index.html", - "main": "apps/example-app-karma/src/main.ts", - "tsConfig": "apps/example-app-karma/tsconfig.app.json", - "assets": ["apps/example-app-karma/src/favicon.ico", "apps/example-app-karma/src/assets"], - "styles": [], - "scripts": [] - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "outputHashing": "all" - }, - "development": { - "buildOptimizer": false, - "optimization": false, - "vendorChunk": true, - "extractLicenses": false, - "sourceMap": true, - "namedChunks": true - } - }, - "defaultConfiguration": "production" - }, - "serve": { - "executor": "@angular-devkit/build-angular:dev-server", - "configurations": { - "production": { - "buildTarget": "example-app-karma:build:production" - }, - "development": { - "buildTarget": "example-app-karma:build:development" - } - }, - "defaultConfiguration": "development", - "continuous": true - }, - "lint": { - "executor": "@nx/eslint:lint" - }, - "test": { - "executor": "@angular-devkit/build-angular:karma", - "options": { - "main": "apps/example-app-karma/src/test.ts", - "tsConfig": "apps/example-app-karma/tsconfig.spec.json", - "karmaConfig": "apps/example-app-karma/karma.conf.js" - } - } - } -} diff --git a/apps/example-app/jest.config.ts b/apps/example-app/jest.config.ts index e0ea9c2..ce394a9 100644 --- a/apps/example-app/jest.config.ts +++ b/apps/example-app/jest.config.ts @@ -1,8 +1,29 @@ -export default { +import type { Config } from 'jest'; + +const config: Config = { displayName: { name: 'Example App', color: 'blue', }, - preset: '../../jest.preset.js', - setupFilesAfterEnv: ['/src/test-setup.ts'], + preset: 'jest-preset-angular', + setupFilesAfterEnv: ['/apps/example-app/src/test-setup.ts'], + testPathIgnorePatterns: ['/node_modules/', '/dist/'], + coverageDirectory: '/coverage/apps/example-app', + transform: { + '^.+\\.(ts|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/apps/example-app/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + ], + }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], }; + +export default config; diff --git a/apps/example-app/project.json b/apps/example-app/project.json deleted file mode 100644 index 1cf90ac..0000000 --- a/apps/example-app/project.json +++ /dev/null @@ -1,75 +0,0 @@ -{ - "name": "example-app", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "projectType": "application", - "sourceRoot": "apps/example-app/src", - "prefix": "app", - "tags": [], - "generators": {}, - "targets": { - "build": { - "executor": "@angular-devkit/build-angular:browser", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/apps/example-app", - "index": "apps/example-app/src/index.html", - "main": "apps/example-app/src/main.ts", - "polyfills": "apps/example-app/src/polyfills.ts", - "tsConfig": "apps/example-app/tsconfig.app.json", - "assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"], - "styles": ["apps/example-app/src/styles.css"], - "scripts": [] - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "anyComponentStyle", - "maximumWarning": "6kb" - } - ], - "outputHashing": "all" - }, - "development": { - "buildOptimizer": false, - "optimization": false, - "vendorChunk": true, - "extractLicenses": false, - "sourceMap": true, - "namedChunks": true - } - }, - "defaultConfiguration": "production" - }, - "serve": { - "executor": "@angular-devkit/build-angular:dev-server", - "configurations": { - "production": { - "buildTarget": "example-app:build:production" - }, - "development": { - "buildTarget": "example-app:build:development" - } - }, - "defaultConfiguration": "development", - "continuous": true - }, - "extract-i18n": { - "executor": "@angular-devkit/build-angular:extract-i18n", - "options": { - "buildTarget": "example-app:build" - } - }, - "lint": { - "executor": "@nx/eslint:lint" - }, - "test": { - "executor": "@nx/jest:jest", - "options": { - "jestConfig": "apps/example-app/jest.config.ts", - "passWithNoTests": false - }, - "outputs": ["{workspaceRoot}/coverage/"] - } - } -} diff --git a/apps/example-app/src/test-setup.ts b/apps/example-app/src/test-setup.ts index 96bfd34..7b0828b 100644 --- a/apps/example-app/src/test-setup.ts +++ b/apps/example-app/src/test-setup.ts @@ -1,4 +1 @@ -import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'; import '@testing-library/jest-dom'; - -setupZoneTestEnv(); diff --git a/jest.config.ts b/jest.config.ts index f5c10f4..8740d68 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,5 +1,2 @@ -const { getJestProjectsAsync } = require('@nx/jest'); - -export default async () => ({ - projects: await getJestProjectsAsync(), -}); +// Root jest configuration - not used directly, projects have their own configs +export default {}; diff --git a/jest.preset.js b/jest.preset.js deleted file mode 100644 index e0cb70c..0000000 --- a/jest.preset.js +++ /dev/null @@ -1,34 +0,0 @@ -const nxPreset = require('@nx/jest/preset').default; - -module.exports = { - ...nxPreset, - testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'], - transform: { - '^.+\\.(ts|mjs|js|html)$': [ - 'jest-preset-angular', - { - tsconfig: '/tsconfig.spec.json', - stringifyContentPathRegex: '\\.(html|svg)$', - }, - ], - }, - transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], - resolver: '@nx/jest/plugins/resolver', - moduleFileExtensions: ['ts', 'js', 'html'], - globals: {}, - snapshotSerializers: [ - 'jest-preset-angular/build/serializers/no-ng-attributes', - 'jest-preset-angular/build/serializers/ng-snapshot', - 'jest-preset-angular/build/serializers/html-comment', - ], - /* TODO: Update to latest Jest snapshotFormat - * By default Nx has kept the older style of Jest Snapshot formats - * to prevent breaking of any existing tests with snapshots. - * It's recommend you update to the latest format. - * You can do this by removing snapshotFormat property - * and running tests with --update-snapshot flag. - * Example: "nx affected --targets=test --update-snapshot" - * More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format - */ - snapshotFormat: { escapeString: true, printBasicPrototype: true }, -}; diff --git a/nx.json b/nx.json deleted file mode 100644 index a308e67..0000000 --- a/nx.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "workspaceLayout": { - "appsDir": "apps", - "libsDir": "projects" - }, - "cli": { - "analytics": false, - "cache": { - "enabled": true, - "path": "./.cache/angular", - "environment": "all" - } - }, - "tasksRunnerOptions": { - "default": { - "options": { - "canTrackAnalytics": false, - "showUsageWarnings": true - } - } - }, - "generators": { - "@nrlw/workspace:library": { - "linter": "eslint", - "unitTestRunner": "jest", - "strict": true, - "standaloneConfig": true, - "buildable": true - }, - "@nx/angular:application": { - "style": "scss", - "linter": "eslint", - "unitTestRunner": "jest", - "e2eTestRunner": "cypress", - "strict": true, - "standaloneConfig": true, - "tags": ["type:app"] - }, - "@nx/angular:library": { - "linter": "eslint", - "unitTestRunner": "jest", - "strict": true, - "standaloneConfig": true, - "publishable": true - }, - "@nx/angular:component": { - "style": "scss", - "displayBlock": true, - "changeDetection": "OnPush" - }, - "@schematics/angular": { - "component": { - "style": "scss", - "displayBlock": true, - "changeDetection": "OnPush" - } - } - }, - "defaultProject": "example-app", - "$schema": "./node_modules/nx/schemas/nx-schema.json", - "targetDefaults": { - "build": { - "dependsOn": ["^build"], - "inputs": ["production", "^production"], - "cache": true - }, - "test": { - "inputs": ["default", "^production"], - "cache": true - }, - "@nx/jest:jest": { - "inputs": ["default", "^production"], - "cache": true, - "options": { - "passWithNoTests": true - }, - "configurations": { - "ci": { - "ci": true, - "codeCoverage": true - } - } - }, - "@nx/eslint:lint": { - "inputs": ["default", "{workspaceRoot}/eslint.config.cjs"], - "cache": true - } - }, - "namedInputs": { - "default": ["{projectRoot}/**/*", "sharedGlobals"], - "sharedGlobals": [], - "production": [ - "default", - "!{projectRoot}/**/*.spec.[jt]s", - "!{projectRoot}/tsconfig.spec.json", - "!{projectRoot}/karma.conf.js", - "!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)", - "!{projectRoot}/jest.config.[jt]s", - "!{projectRoot}/eslint.config.cjs", - "!{projectRoot}/src/test-setup.[jt]s" - ] - }, - "nxCloudAccessToken": "M2Q4YjlkNjMtMzY1NC00ZjkwLTk1ZjgtZjg5Y2VkMzFjM2FifHJlYWQtd3JpdGU=", - "parallel": 3, - "useInferencePlugins": false, - "defaultBase": "main" -} diff --git a/package.json b/package.json index 14b0bda..cdb8e8d 100644 --- a/package.json +++ b/package.json @@ -2,26 +2,17 @@ "name": "@testing-library/angular-app", "version": "0.0.0-semantically-released", "scripts": { - "ng": "nx", - "nx": "nx", - "start": "nx serve", + "ng": "ng", "prebuild": "rimraf dist", - "build": "nx run-many --target=build --projects=testing-library", + "build": "ng build testing-library && npm run build:schematics && cpy ./README.md ./dist/@testing-library/angular", "build:schematics": "tsc -p ./projects/testing-library/tsconfig.schematics.json", - "test": "nx run-many --target=test --all --parallel=1", - "lint": "nx run-many --all --target=lint", - "e2e": "nx e2e", - "affected:apps": "nx affected:apps", - "affected:libs": "nx affected:libs", - "affected:build": "nx affected:build", - "affected:e2e": "nx affected:e2e", - "affected:test": "nx affected:test", - "affected:lint": "nx affected:lint", - "affected:dep-graph": "nx affected:dep-graph", - "affected": "nx affected", - "format": "nx format:write", - "format:write": "nx format:write", - "format:check": "nx format:check", + "test": "ng test", + "test:testing-library": "ng test testing-library", + "test:example-app": "ng test example-app", + "lint": "ng lint", + "lint:all": "ng lint testing-library && ng lint example-app && ng lint example-app-karma", + "format": "prettier --write .", + "format:check": "prettier --check .", "pre-commit": "lint-staged", "semantic-release": "semantic-release", "prepare": "git config core.hookspath .githooks" @@ -37,13 +28,13 @@ "@angular/platform-browser-dynamic": "20.3.10", "@angular/router": "20.3.10", "@ngrx/store": "20.0.0", - "@nx/angular": "22.0.2", "@testing-library/dom": "^10.4.1", "rxjs": "7.8.0", "tslib": "~2.8.1", "zone.js": "^0.15.1" }, "devDependencies": { + "@angular-builders/jest": "^20.0.0", "@angular-devkit/build-angular": "20.3.9", "@angular-devkit/core": "20.3.9", "@angular-devkit/schematics": "20.3.9", @@ -57,12 +48,6 @@ "@angular/forms": "20.3.10", "@angular/language-service": "20.3.10", "@eslint/eslintrc": "^3.3.1", - "@nx/eslint": "22.0.2", - "@nx/eslint-plugin": "22.0.2", - "@nx/jest": "22.0.2", - "@nx/node": "22.0.2", - "@nx/plugin": "22.0.2", - "@nx/workspace": "22.0.2", "@schematics/angular": "20.3.9", "@testing-library/jasmine-dom": "^1.3.3", "@testing-library/jest-dom": "^6.9.1", @@ -93,7 +78,6 @@ "lint-staged": "^16.2.6", "ng-mocks": "^14.14.0", "ng-packagr": "20.3.0", - "nx": "22.0.2", "postcss": "^8.5.6", "postcss-import": "14.1.0", "postcss-preset-env": "7.5.0", diff --git a/projects/testing-library/jest-utils/tests/create-mock.spec.ts b/projects/testing-library/jest-utils/tests/create-mock.spec.ts index c20109b..9802b46 100644 --- a/projects/testing-library/jest-utils/tests/create-mock.spec.ts +++ b/projects/testing-library/jest-utils/tests/create-mock.spec.ts @@ -1,6 +1,6 @@ import { Component, inject } from '@angular/core'; import { TestBed } from '@angular/core/testing'; -import { fireEvent, render, screen } from '@testing-library/angular'; +import { fireEvent, render, screen } from '../../src/public_api'; import { createMock, provideMock, provideMockWithValues, Mock } from '../src/public_api'; diff --git a/projects/testing-library/jest.config.ts b/projects/testing-library/jest.config.ts index bc5a665..7d19854 100644 --- a/projects/testing-library/jest.config.ts +++ b/projects/testing-library/jest.config.ts @@ -1,8 +1,29 @@ -export default { +import type { Config } from 'jest'; + +const config: Config = { displayName: { name: 'ATL', color: 'magenta', }, - preset: '../../jest.preset.js', - setupFilesAfterEnv: ['/test-setup.ts'], + preset: 'jest-preset-angular', + setupFilesAfterEnv: ['/projects/testing-library/test-setup.ts'], + testPathIgnorePatterns: ['/node_modules/', '/dist/'], + coverageDirectory: '/coverage/projects/testing-library', + transform: { + '^.+\\.(ts|js|html)$': [ + 'jest-preset-angular', + { + tsconfig: '/projects/testing-library/tsconfig.spec.json', + stringifyContentPathRegex: '\\.(html|svg)$', + }, + ], + }, + transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], + snapshotSerializers: [ + 'jest-preset-angular/build/serializers/no-ng-attributes', + 'jest-preset-angular/build/serializers/ng-snapshot', + 'jest-preset-angular/build/serializers/html-comment', + ], }; + +export default config; diff --git a/projects/testing-library/project.json b/projects/testing-library/project.json deleted file mode 100644 index 1deb065..0000000 --- a/projects/testing-library/project.json +++ /dev/null @@ -1,54 +0,0 @@ -{ - "name": "testing-library", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "projectType": "library", - "sourceRoot": "projects/testing-library/src", - "prefix": "lib", - "tags": [], - "targets": { - "build-package": { - "executor": "@nx/angular:package", - "outputs": ["{workspaceRoot}/dist/@testing-library/angular"], - "options": { - "project": "projects/testing-library/ng-package.json" - }, - "configurations": { - "production": { - "tsConfig": "projects/testing-library/tsconfig.lib.prod.json" - }, - "development": { - "tsConfig": "projects/testing-library/tsconfig.lib.json" - } - }, - "defaultConfiguration": "production" - }, - "lint": { - "executor": "@nx/eslint:lint" - }, - "build": { - "executor": "nx:run-commands", - "options": { - "parallel": false, - "commands": [ - { - "command": "nx run testing-library:build-package" - }, - { - "command": "npm run build:schematics" - }, - { - "command": "cpy ./README.md ./dist/@testing-library/angular" - } - ] - } - }, - "test": { - "executor": "@nx/jest:jest", - "options": { - "jestConfig": "projects/testing-library/jest.config.ts", - "passWithNoTests": false - }, - "outputs": ["{workspaceRoot}/coverage/projects/testing-library"] - } - } -} diff --git a/projects/testing-library/schematics/migrations/dtl-as-dev-dependency/index.spec.ts b/projects/testing-library/schematics/migrations/dtl-as-dev-dependency/index.spec.ts index ebc3922..98b7acc 100644 --- a/projects/testing-library/schematics/migrations/dtl-as-dev-dependency/index.spec.ts +++ b/projects/testing-library/schematics/migrations/dtl-as-dev-dependency/index.spec.ts @@ -8,8 +8,8 @@ test('adds DTL to devDependencies', async () => { expect(pkg).toMatchInlineSnapshot(` "{ - \\"devDependencies\\": { - \\"@testing-library/dom\\": \\"^10.0.0\\" + "devDependencies": { + "@testing-library/dom": "^10.0.0" } }" `); @@ -19,14 +19,14 @@ test('ignores if DTL is already listed as a dev dependency', async () => { const tree = await setup({ devDependencies: { '@testing-library/dom': '^9.0.0' } }); const pkg = tree.readContent('package.json'); - expect(pkg).toMatchInlineSnapshot(`"{\\"devDependencies\\":{\\"@testing-library/dom\\":\\"^9.0.0\\"}}"`); + expect(pkg).toMatchInlineSnapshot(`"{"devDependencies":{"@testing-library/dom":"^9.0.0"}}"`); }); test('ignores if DTL is already listed as a dependency', async () => { const tree = await setup({ dependencies: { '@testing-library/dom': '^11.0.0' } }); const pkg = tree.readContent('package.json'); - expect(pkg).toMatchInlineSnapshot(`"{\\"dependencies\\":{\\"@testing-library/dom\\":\\"^11.0.0\\"}}"`); + expect(pkg).toMatchInlineSnapshot(`"{"dependencies":{"@testing-library/dom":"^11.0.0"}}"`); }); async function setup(packageJson: object) { diff --git a/projects/testing-library/test-setup.ts b/projects/testing-library/test-setup.ts index be311bf..c465392 100644 --- a/projects/testing-library/test-setup.ts +++ b/projects/testing-library/test-setup.ts @@ -1,7 +1,4 @@ -import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'; import '@testing-library/jest-dom'; import { TextEncoder, TextDecoder } from 'util'; -setupZoneTestEnv(); - Object.assign(global, { TextDecoder, TextEncoder }); diff --git a/projects/testing-library/tests/issues/issue-318.spec.ts b/projects/testing-library/tests/issues/issue-318.spec.ts index 1cfe5b8..6e4acd9 100644 --- a/projects/testing-library/tests/issues/issue-318.spec.ts +++ b/projects/testing-library/tests/issues/issue-318.spec.ts @@ -2,7 +2,7 @@ import { Component, inject, OnDestroy, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { Subject, takeUntil } from 'rxjs'; -import { render } from '@testing-library/angular'; +import { render } from '../../src/public_api'; @Component({ selector: 'atl-app-fixture', diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..b11a869 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "baseUrl": "./", + "outDir": "./dist/out-tsc", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "sourceMap": true, + "declaration": false, + "downlevelIteration": true, + "experimentalDecorators": true, + "moduleResolution": "node", + "importHelpers": true, + "target": "ES2022", + "module": "ES2022", + "useDefineForClassFields": false, + "lib": ["ES2022", "dom"] + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + } +} diff --git a/tsconfig.spec.json b/tsconfig.spec.json new file mode 100644 index 0000000..febf2a2 --- /dev/null +++ b/tsconfig.spec.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "./out-tsc/spec", + "types": ["jest", "node", "@testing-library/jest-dom"] + }, + "include": ["**/*.spec.ts", "**/*.d.ts"] +}