Skip to content

Commit

Permalink
chore: fix up test configs
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn committed Sep 11, 2024
1 parent 1e863ee commit 243cbde
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 19 deletions.
3 changes: 3 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"test": {
"builder": "@angular-devkit/build-angular:jest",
"options": {
"exclude": [
"**/schematics/ng-add/*.spec.ts"
],
"tsConfig": "projects/angular-redux/tsconfig.spec.json",
"polyfills": [
"zone.js",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test"
"test": "yarn test:ng && yarn test:schematics",
"test:ng": "ng test",
"test:schematics": "cd projects/angular-redux/schematics && jest"
},
"workspaces": {
"packages": [
Expand Down Expand Up @@ -44,6 +46,7 @@
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"ng-packagr": "^18.2.0",
"ts-jest": "^29.2.5",
"typescript": "~5.5.2"
},
"packageManager": "[email protected]"
Expand Down
8 changes: 4 additions & 4 deletions projects/angular-redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
"peerDependencies": {
"@angular/common": ">=17.3.0",
"@angular/core": ">=17.3.0",
"redux": "^5.0.0",
"@reduxjs/toolkit": "^2.2.7"
"@reduxjs/toolkit": "^2.2.7",
"redux": "^5.0.0"
},
"peerDependenciesMeta": {
"redux": {
"@reduxjs/toolkit": {
"optional": true
},
"@reduxjs/toolkit": {
"redux": {
"optional": true
}
},
Expand Down
2 changes: 0 additions & 2 deletions projects/angular-redux/schematics-core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ export const stringUtils = {
pluralize,
};

export { updatePackage } from './utility/update';

export { parseName } from './utility/parse-name';

export { addPackageToPackageJson } from './utility/package';
Expand Down
5 changes: 3 additions & 2 deletions projects/angular-redux/schematics-core/utility/project.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { TargetDefinition } from '@angular-devkit/core/src/workspace';
// import { TargetDefinition } from '@angular-devkit/core/src/workspace';
import { getWorkspace } from './config';
import { SchematicsException, Tree } from '@angular-devkit/schematics';

export interface WorkspaceProject {
root: string;
projectType: string;
architect: {
[key: string]: TargetDefinition;
// [key: string]: TargetDefinition;
[key: string]: any;
};
}

Expand Down
13 changes: 13 additions & 0 deletions projects/angular-redux/schematics/jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
displayName: 'Schematics',
coverageDirectory: '../../coverage/modules/schematics',
transform: {
'^.+\\.(ts|mjs|js)$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json'
},
],
},
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)']
};
6 changes: 1 addition & 5 deletions projects/angular-redux/schematics/ng-add/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as fs from "fs";
import * as path from "path";
import { fileURLToPath } from 'url';
import * as ts from 'typescript';
import {
Rule,
Expand Down Expand Up @@ -95,10 +94,7 @@ function addImportToNgModule(options: AngularReduxOptions): Rule {
};
}

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const angularReduxPackageMeta = fs.readFile(path.resolve(__dirname, '../../package.json')) as {
const angularReduxPackageMeta = fs.readFileSync(path.resolve(__dirname, '../../package.json')) as unknown as {
version: string;
peerDependencies: {
[key: string]: string;
Expand Down
15 changes: 15 additions & 0 deletions projects/angular-redux/schematics/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"emitDecoratorMetadata": true,
"types": [
"jest",
"node"
]
},
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
4 changes: 4 additions & 0 deletions projects/angular-redux/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@
"include": [
"**/*.spec.ts",
"**/*.d.ts"
],
"exclude": [
"./schematics/**/*.ts",
"./schematics-core/**/*.ts"
]
}
124 changes: 119 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3162,6 +3162,7 @@ __metadata:
ng-packagr: "npm:^18.2.0"
redux: "npm:^5.0.1"
rxjs: "npm:~7.8.0"
ts-jest: "npm:^29.2.5"
tslib: "npm:^2.3.0"
typescript: "npm:~5.5.2"
zone.js: "npm:~0.14.10"
Expand All @@ -3176,8 +3177,11 @@ __metadata:
peerDependencies:
"@angular/common": ">=17.3.0"
"@angular/core": ">=17.3.0"
"@reduxjs/toolkit": ^2.2.7
redux: ^5.0.0
peerDependenciesMeta:
"@reduxjs/toolkit":
optional: true
redux:
optional: true
languageName: unknown
Expand Down Expand Up @@ -4499,6 +4503,13 @@ __metadata:
languageName: node
linkType: hard

"async@npm:^3.2.3":
version: 3.2.6
resolution: "async@npm:3.2.6"
checksum: 10/cb6e0561a3c01c4b56a799cc8bab6ea5fef45f069ab32500b6e19508db270ef2dffa55e5aed5865c5526e9907b1f8be61b27530823b411ffafb5e1538c86c368
languageName: node
linkType: hard

"asynckit@npm:^0.4.0":
version: 0.4.0
resolution: "asynckit@npm:0.4.0"
Expand Down Expand Up @@ -4777,6 +4788,15 @@ __metadata:
languageName: node
linkType: hard

"bs-logger@npm:^0.2.6":
version: 0.2.6
resolution: "bs-logger@npm:0.2.6"
dependencies:
fast-json-stable-stringify: "npm:2.x"
checksum: 10/e6d3ff82698bb3f20ce64fb85355c5716a3cf267f3977abe93bf9c32a2e46186b253f48a028ae5b96ab42bacd2c826766d9ae8cf6892f9b944656be9113cf212
languageName: node
linkType: hard

"bser@npm:2.1.1":
version: 2.1.1
resolution: "bser@npm:2.1.1"
Expand Down Expand Up @@ -4915,7 +4935,7 @@ __metadata:
languageName: node
linkType: hard

"chalk@npm:^4.0.0, chalk@npm:^4.1.0":
"chalk@npm:^4.0.0, chalk@npm:^4.0.2, chalk@npm:^4.1.0":
version: 4.1.2
resolution: "chalk@npm:4.1.2"
dependencies:
Expand Down Expand Up @@ -5685,6 +5705,17 @@ __metadata:
languageName: node
linkType: hard

"ejs@npm:^3.1.10":
version: 3.1.10
resolution: "ejs@npm:3.1.10"
dependencies:
jake: "npm:^10.8.5"
bin:
ejs: bin/cli.js
checksum: 10/a9cb7d7cd13b7b1cd0be5c4788e44dd10d92f7285d2f65b942f33e127230c054f99a42db4d99f766d8dbc6c57e94799593ee66a14efd7c8dd70c4812bf6aa384
languageName: node
linkType: hard

"electron-to-chromium@npm:^1.5.4":
version: 1.5.18
resolution: "electron-to-chromium@npm:1.5.18"
Expand Down Expand Up @@ -6324,7 +6355,7 @@ __metadata:
languageName: node
linkType: hard

"fast-json-stable-stringify@npm:^2.0.0, fast-json-stable-stringify@npm:^2.1.0":
"fast-json-stable-stringify@npm:2.x, fast-json-stable-stringify@npm:^2.0.0, fast-json-stable-stringify@npm:^2.1.0":
version: 2.1.0
resolution: "fast-json-stable-stringify@npm:2.1.0"
checksum: 10/2c20055c1fa43c922428f16ca8bb29f2807de63e5c851f665f7ac9790176c01c3b40335257736b299764a8d383388dabc73c8083b8e1bc3d99f0a941444ec60e
Expand Down Expand Up @@ -6365,6 +6396,15 @@ __metadata:
languageName: node
linkType: hard

"filelist@npm:^1.0.4":
version: 1.0.4
resolution: "filelist@npm:1.0.4"
dependencies:
minimatch: "npm:^5.0.1"
checksum: 10/4b436fa944b1508b95cffdfc8176ae6947b92825483639ef1b9a89b27d82f3f8aa22b21eed471993f92709b431670d4e015b39c087d435a61e1bb04564cf51de
languageName: node
linkType: hard

"fill-range@npm:^7.1.1":
version: 7.1.1
resolution: "fill-range@npm:7.1.1"
Expand Down Expand Up @@ -7402,6 +7442,20 @@ __metadata:
languageName: node
linkType: hard

"jake@npm:^10.8.5":
version: 10.9.2
resolution: "jake@npm:10.9.2"
dependencies:
async: "npm:^3.2.3"
chalk: "npm:^4.0.2"
filelist: "npm:^1.0.4"
minimatch: "npm:^3.1.2"
bin:
jake: bin/cli.js
checksum: 10/3be324708f99f031e0aec49ef8fd872eb4583cbe8a29a0c875f554f6ac638ee4ea5aa759bb63723fd54f77ca6d7db851eaa78353301734ed3700db9cb109a0cd
languageName: node
linkType: hard

"jasmine-core@npm:~5.2.0":
version: 5.2.0
resolution: "jasmine-core@npm:5.2.0"
Expand Down Expand Up @@ -7794,7 +7848,7 @@ __metadata:
languageName: node
linkType: hard

"jest-util@npm:^29.7.0":
"jest-util@npm:^29.0.0, jest-util@npm:^29.7.0":
version: 29.7.0
resolution: "jest-util@npm:29.7.0"
dependencies:
Expand Down Expand Up @@ -8245,6 +8299,13 @@ __metadata:
languageName: node
linkType: hard

"lodash.memoize@npm:^4.1.2":
version: 4.1.2
resolution: "lodash.memoize@npm:4.1.2"
checksum: 10/192b2168f310c86f303580b53acf81ab029761b9bd9caa9506a019ffea5f3363ea98d7e39e7e11e6b9917066c9d36a09a11f6fe16f812326390d8f3a54a1a6da
languageName: node
linkType: hard

"lodash@npm:^4.17.21":
version: 4.17.21
resolution: "lodash@npm:4.17.21"
Expand Down Expand Up @@ -8337,6 +8398,13 @@ __metadata:
languageName: node
linkType: hard

"make-error@npm:^1.3.6":
version: 1.3.6
resolution: "make-error@npm:1.3.6"
checksum: 10/b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402
languageName: node
linkType: hard

"make-fetch-happen@npm:^13.0.0, make-fetch-happen@npm:^13.0.1":
version: 13.0.1
resolution: "make-fetch-happen@npm:13.0.1"
Expand Down Expand Up @@ -8495,7 +8563,7 @@ __metadata:
languageName: node
linkType: hard

"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1":
"minimatch@npm:^3.0.4, minimatch@npm:^3.1.1, minimatch@npm:^3.1.2":
version: 3.1.2
resolution: "minimatch@npm:3.1.2"
dependencies:
Expand All @@ -8504,6 +8572,15 @@ __metadata:
languageName: node
linkType: hard

"minimatch@npm:^5.0.1":
version: 5.1.6
resolution: "minimatch@npm:5.1.6"
dependencies:
brace-expansion: "npm:^2.0.1"
checksum: 10/126b36485b821daf96d33b5c821dac600cc1ab36c87e7a532594f9b1652b1fa89a1eebcaad4dff17c764dce1a7ac1531327f190fed5f97d8f6e5f889c116c429
languageName: node
linkType: hard

"minimatch@npm:^9.0.0, minimatch@npm:^9.0.4":
version: 9.0.5
resolution: "minimatch@npm:9.0.5"
Expand Down Expand Up @@ -10242,7 +10319,7 @@ __metadata:
languageName: node
linkType: hard

"semver@npm:7.6.3, semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.3.5, semver@npm:^7.5.3, semver@npm:^7.5.4":
"semver@npm:7.6.3, semver@npm:^7.0.0, semver@npm:^7.1.1, semver@npm:^7.3.5, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.3":
version: 7.6.3
resolution: "semver@npm:7.6.3"
bin:
Expand Down Expand Up @@ -10985,6 +11062,43 @@ __metadata:
languageName: node
linkType: hard

"ts-jest@npm:^29.2.5":
version: 29.2.5
resolution: "ts-jest@npm:29.2.5"
dependencies:
bs-logger: "npm:^0.2.6"
ejs: "npm:^3.1.10"
fast-json-stable-stringify: "npm:^2.1.0"
jest-util: "npm:^29.0.0"
json5: "npm:^2.2.3"
lodash.memoize: "npm:^4.1.2"
make-error: "npm:^1.3.6"
semver: "npm:^7.6.3"
yargs-parser: "npm:^21.1.1"
peerDependencies:
"@babel/core": ">=7.0.0-beta.0 <8"
"@jest/transform": ^29.0.0
"@jest/types": ^29.0.0
babel-jest: ^29.0.0
jest: ^29.0.0
typescript: ">=4.3 <6"
peerDependenciesMeta:
"@babel/core":
optional: true
"@jest/transform":
optional: true
"@jest/types":
optional: true
babel-jest:
optional: true
esbuild:
optional: true
bin:
ts-jest: cli.js
checksum: 10/f89e562816861ec4510840a6b439be6145f688b999679328de8080dc8e66481325fc5879519b662163e33b7578f35243071c38beb761af34e5fe58e3e326a958
languageName: node
linkType: hard

"tslib@npm:2.6.3":
version: 2.6.3
resolution: "tslib@npm:2.6.3"
Expand Down

0 comments on commit 243cbde

Please sign in to comment.