Skip to content

Commit 2fa0325

Browse files
Update for Jest
1 parent 94a3d31 commit 2fa0325

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+4063
-2536
lines changed

.browserslistrc

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1 @@
1-
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2-
# For additional information regarding the format and rule options, please see:
3-
# https://github.com/browserslist/browserslist#queries
4-
5-
# You can see what browsers were selected by your queries by running:
6-
# npx browserslist
7-
8-
> 0.5%
9-
last 2 Chrome versions
10-
last 2 Firefox versions
11-
last 2 Edge versions
12-
last 2 Safari versions
13-
Firefox ESR
14-
not dead
15-
not IE 11 # IE is obsolete; modern Angular no longer supports it
1+
defaults

.github/workflows/gh-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
# Builds the Angular app
3232
- name: Build Angular
3333
run: |
34-
ng build lib
34+
ng build angularx-social-login
3535
ng build --configuration production --output-path docs --base-href /angularx-social-login/
3636
3737
- uses: EndBug/add-and-commit@v7

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.5.1
2+
- Update build
3+
- Migrate to JEST
4+
15
# 2.5.0
26
- Update to Angular 20
37
- Update several dependencies

angular.json

Lines changed: 73 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,50 @@
33
"version": 1,
44
"newProjectRoot": "projects",
55
"projects": {
6-
"angularx-social-login-ws": {
7-
"projectType": "application",
8-
"schematics": {},
6+
"angularx-social-login-demo": {
97
"root": "",
108
"sourceRoot": "src",
9+
"projectType": "application",
1110
"prefix": "app",
11+
"schematics": {
12+
"@schematics/angular:application": {
13+
"strict": true
14+
},
15+
"@schematics/angular:component": {
16+
"style": "scss",
17+
"skipTests": true
18+
},
19+
"@schematics/angular:class": {
20+
"skipTests": true
21+
},
22+
"@schematics/angular:directive": {
23+
"skipTests": true
24+
},
25+
"@schematics/angular:guard": {
26+
"skipTests": true
27+
},
28+
"@schematics/angular:module": {
29+
"skipTests": true
30+
},
31+
"@schematics/angular:pipe": {
32+
"skipTests": true
33+
},
34+
"@schematics/angular:service": {
35+
"skipTests": true
36+
}
37+
},
1238
"architect": {
1339
"build": {
1440
"builder": "@angular-devkit/build-angular:application",
1541
"options": {
42+
"aot": true,
1643
"outputPath": {
17-
"base": "dist/angularx-social-login-ws"
44+
"base": "dist/angularx-social-login-demo"
1845
},
1946
"index": "src/index.html",
20-
"polyfills": [
21-
"src/polyfills.ts"
22-
],
23-
"tsConfig": "tsconfig.app.json",
24-
"assets": [
25-
"src/favicon.ico",
26-
"src/assets"
27-
],
28-
"styles": [
29-
"src/styles.css"
30-
],
47+
"tsConfig": "src/tsconfig.app.json",
48+
"assets": ["src/favicon.ico", "src/assets"],
49+
"styles": ["src/styles.scss"],
3150
"scripts": [],
3251
"extractLicenses": false,
3352
"sourceMap": true,
@@ -37,6 +56,12 @@
3756
},
3857
"configurations": {
3958
"production": {
59+
"budgets": [
60+
{
61+
"type": "anyComponentStyle",
62+
"maximumWarning": "6kb"
63+
}
64+
],
4065
"fileReplacements": [
4166
{
4267
"replace": "src/environments/environment.ts",
@@ -47,113 +72,95 @@
4772
"outputHashing": "all",
4873
"sourceMap": false,
4974
"namedChunks": false,
50-
"extractLicenses": true,
51-
"budgets": [
52-
{
53-
"type": "initial",
54-
"maximumWarning": "2mb",
55-
"maximumError": "5mb"
56-
},
57-
{
58-
"type": "anyComponentStyle",
59-
"maximumWarning": "6kb",
60-
"maximumError": "10kb"
61-
}
62-
]
75+
"aot": true,
76+
"extractLicenses": true
6377
}
64-
},
65-
"defaultConfiguration": ""
78+
}
6679
},
6780
"serve": {
6881
"builder": "@angular-devkit/build-angular:dev-server",
6982
"options": {
70-
"buildTarget": "angularx-social-login-ws:build"
83+
"buildTarget": "angularx-social-login-demo:build"
7184
},
7285
"configurations": {
7386
"production": {
74-
"buildTarget": "angularx-social-login-ws:build:production"
87+
"buildTarget": "angularx-social-login-demo:build:production"
7588
}
7689
}
7790
},
7891
"extract-i18n": {
7992
"builder": "@angular-devkit/build-angular:extract-i18n",
8093
"options": {
81-
"buildTarget": "angularx-social-login-ws:build"
94+
"buildTarget": "angularx-social-login-demo:build"
8295
}
8396
},
8497
"test": {
85-
"builder": "@angular-devkit/build-angular:karma",
98+
"builder": "@angular-builders/jest:run",
8699
"options": {
87-
"main": "src/test.ts",
88-
"polyfills": "src/polyfills.ts",
89100
"tsConfig": "tsconfig.spec.json",
90-
"karmaConfig": "karma.conf.js",
91-
"assets": [
92-
"src/favicon.ico",
93-
"src/assets"
94-
],
95-
"styles": [
96-
"src/styles.css"
97-
],
98-
"scripts": []
101+
"styles": ["src/styles.scss"],
102+
"scripts": [],
103+
"assets": ["src/favicon.ico", "src/assets"],
104+
"configPath": "jest-config.js",
105+
"watch": false
99106
}
100107
},
101108
"lint": {
102109
"builder": "@angular-eslint/builder:lint",
103110
"options": {
104-
"lintFilePatterns": [
105-
"src/**/*.ts",
106-
"src/**/*.html"
107-
]
111+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
108112
}
109-
},
113+
}
114+
}
115+
},
116+
"angularx-social-login-demo-e2e": {
117+
"root": "e2e/",
118+
"projectType": "application",
119+
"architect": {
110120
"e2e": {
111121
"builder": "@angular-devkit/build-angular:protractor",
112122
"options": {
113123
"protractorConfig": "e2e/protractor.conf.js",
114-
"devServerTarget": "angularx-social-login-ws:serve"
124+
"devServerTarget": "angularx-social-login-demo:serve"
115125
},
116126
"configurations": {
117127
"production": {
118-
"devServerTarget": "angularx-social-login-ws:serve:production"
128+
"devServerTarget": "angularx-social-login-demo:serve:production"
119129
}
120130
}
121131
}
122132
}
123133
},
124-
"lib": {
134+
"angularx-social-login": {
135+
"root": "projects/angularx-social-login",
136+
"sourceRoot": "projects/angularx-social-login/src",
125137
"projectType": "library",
126-
"root": "projects/lib",
127-
"sourceRoot": "projects/lib/src",
128138
"prefix": "lib",
129139
"architect": {
130140
"build": {
131141
"builder": "@angular-devkit/build-angular:ng-packagr",
132142
"options": {
133-
"tsConfig": "projects/lib/tsconfig.lib.json",
134-
"project": "projects/lib/ng-package.json"
143+
"tsConfig": "projects/angularx-social-login/tsconfig.lib.json",
144+
"project": "projects/angularx-social-login/ng-package.json"
135145
},
136146
"configurations": {
137147
"production": {
138-
"tsConfig": "projects/lib/tsconfig.lib.prod.json"
148+
"project": "projects/angularx-social-login/ng-package.prod.json",
149+
"tsConfig": "projects/angularx-social-login/tsconfig.lib.prod.json"
139150
}
140151
}
141152
},
142153
"test": {
143-
"builder": "@angular-devkit/build-angular:karma",
154+
"builder": "@angular-builders/jest:run",
144155
"options": {
145-
"main": "projects/lib/src/test.ts",
146-
"tsConfig": "projects/lib/tsconfig.spec.json",
147-
"karmaConfig": "projects/lib/karma.conf.js"
156+
"tsConfig": "tsconfig.spec.json",
157+
"configPath": "jest-config.js"
148158
}
149159
},
150160
"lint": {
151161
"builder": "@angular-eslint/builder:lint",
152162
"options": {
153-
"lintFilePatterns": [
154-
"projects/lib/**/*.ts",
155-
"projects/lib/**/*.html"
156-
]
163+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
157164
}
158165
}
159166
}

e2e/tsconfig.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "../out-tsc/e2e",
4+
"outDir": "../out-tsc/app",
55
"module": "commonjs",
6-
"target": "ES2022",
6+
"target": "es5",
77
"types": [
8-
"jasmine",
9-
"jasminewd2",
8+
"jest",
109
"node"
1110
]
1211
}

jest-config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @type {import('jest').Config} */
2+
const config = {
3+
moduleNameMapper: {
4+
'^angularx-social-login$': '<rootDir>/projects/angularx-social-login/src/public-api.ts',
5+
},
6+
preset: 'jest-preset-angular',
7+
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
8+
clearMocks: true,
9+
collectCoverage: true,
10+
coverageDirectory: 'coverage',
11+
coverageProvider: 'v8',
12+
testEnvironment: 'jsdom',
13+
};
14+
15+
module.exports = config;

karma.conf.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

package.json

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
7-
"build-lib": "ng build lib",
8-
"build-lib-prod": "ng build lib --configuration production",
9-
"deploy": "cd dist/lib && npm publish",
7+
"build-lib": "ng build angularx-social-login",
8+
"build-lib-prod": "ng build angularx-social-login --configuration production",
9+
"deploy": "cd dist/angularx-social-login && npm publish",
1010
"build": "ng build",
1111
"test": "ng test",
1212
"lint": "ng lint",
@@ -28,6 +28,7 @@
2828
"zone.js": "~0.15.1"
2929
},
3030
"devDependencies": {
31+
"@angular-builders/jest": "^20.0.0",
3132
"@angular-devkit/build-angular": "^20.1.3",
3233
"@angular-eslint/builder": "20.1.1",
3334
"@angular-eslint/eslint-plugin": "20.1.1",
@@ -37,26 +38,22 @@
3738
"@angular/cli": "^20.1.3",
3839
"@angular/compiler-cli": "^20.1.3",
3940
"@angular/language-service": "^20.1.3",
41+
"@testing-library/jest-dom": "6.6.3",
4042
"@types/google.accounts": "^0.0.17",
41-
"@types/karma": "^6.3.9",
42-
"@types/jasmine": "^5.1.8",
43-
"@types/jasminewd2": "^2.0.13",
43+
"@types/jest": "^30.0.0",
4444
"@types/node": "^24.1.0",
4545
"@typescript-eslint/eslint-plugin": "^8.33.1",
4646
"@typescript-eslint/parser": "^8.33.1",
4747
"eslint": "^9.28.0",
4848
"husky": "^9.1.7",
49-
"jasmine-core": "~5.9.0",
50-
"jasmine-spec-reporter": "~7.0.0",
51-
"karma": "~6.4.4",
52-
"karma-chrome-launcher": "~3.2.0",
53-
"karma-coverage-istanbul-reporter": "~3.0.3",
54-
"karma-jasmine": "~5.1.0",
55-
"karma-jasmine-html-reporter": "^2.1.0",
49+
"jasmine-spec-reporter": "^7.0.0",
50+
"jest": "30.0.5",
51+
"jest-preset-angular": "^15.0.0",
5652
"lint-staged": "^16.1.2",
5753
"ng-packagr": "^20.1.0",
5854
"protractor": "~7.0.0",
59-
"ts-node": "~10.9.2",
55+
"ts-jest": "29.4.0",
56+
"ts-node": "^10.9.2",
6057
"typescript": "5.8.3"
6158
},
6259
"engines": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,6 @@ this.authService.signIn(FacebookLoginProvider.PROVIDER_ID, fbLoginOptions);
387387
## Running the demo app
388388
389389
```sh
390-
ng build lib
390+
ng build angularx-social-login
391391
ng serve
392392
```

0 commit comments

Comments
 (0)