Skip to content

Commit b925ff7

Browse files
maxi7587pablorsk
authored andcommitted
Karma removed (#82)
* improved ngx-jsonapi.module test * jest working to demo * updated angular.cli and deleted unnecesary files
1 parent 5b27162 commit b925ff7

10 files changed

+158
-177
lines changed

.angular-cli.json

-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
"project": "e2e/tsconfig.e2e.json"
4444
}
4545
],
46-
"test": {
47-
"karma": {
48-
"config": "./karma.conf.js"
49-
}
50-
},
5146
"defaults": {
5247
"styleExt": "css",
5348
"build": {

demo/test.ts

-28
This file was deleted.

demo/tsconfig.spec.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"module": "commonjs",
1414
"target": "es6",
1515
"types": [
16-
"jasmine",
16+
"jest",
1717
"node"
1818
],
1919
"baseUrl": ".",
@@ -22,9 +22,6 @@
2222
"ngx-jsonapi": [ "../src" ]
2323
}
2424
},
25-
"files": [
26-
"test.ts"
27-
],
2825
"include": [
2926
"**/*.spec.ts"
3027
]

karma.conf.js

-42
This file was deleted.

package.json

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "ngx-jsonapi",
3-
"description": "JSON API library for Angular",
2+
"name": "ngx-jsonapi-demo",
3+
"description": "Demo app for JSON API library for Angular",
44
"scripts": {
55
"build": "ts-node ./build/index.ts",
66
"postbuild": "rimraf **/dist/**/*.ngsummary.json",
@@ -131,12 +131,6 @@
131131
"jest": "^21.0.2",
132132
"jest-preset-angular": "^3.0.1",
133133
"jest-zone-patch": "^0.0.7",
134-
"karma": "~1.4.1",
135-
"karma-chrome-launcher": "~2.0.0",
136-
"karma-cli": "~1.0.1",
137-
"karma-coverage-istanbul-reporter": "^0.2.0",
138-
"karma-jasmine": "~1.1.0",
139-
"karma-jasmine-html-reporter": "^0.2.2",
140134
"module-alias": "^2.0.0",
141135
"ncp": "^2.0.0",
142136
"nyc": "^10.1.2",
@@ -190,7 +184,8 @@
190184
"node_modules/(?!ngx-jsonapi)"
191185
],
192186
"modulePathIgnorePatterns": [
193-
"dist"
187+
"dist",
188+
"node_modules/ngx-jsonapi"
194189
]
195190
}
196191
}

setup-jest.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ global['CSS'] = null;
66
* Workaround for JSDOM missing transform property
77
*/
88
Object.defineProperty(document.body.style, 'transform', {
9-
value: () => {
9+
value: (): Object => {
1010
return {
1111
enumerable: true,
12-
configurable: true,
12+
configurable: true
1313
};
14-
},
14+
}
1515
});

src/ngx-jsonapi.spec.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { NgxJsonapiModule } from '.';
2-
import { JsonapiCore } from '.';
1+
import { JsonapiCore, NgxJsonapiModule } from '.';
32

43
/*
54
This file is to import the main module. By importing it into this
@@ -14,9 +13,7 @@ describe('ngx-jsonapi Module', () => {
1413

1514
it('should throw error when imported more than once', () => {
1615
expect(
17-
(): void => {
18-
new NgxJsonapiModule(NgxJsonapiModule, new JsonapiCore(undefined, undefined, undefined));
19-
}
16+
(): NgxJsonapiModule => new NgxJsonapiModule(NgxJsonapiModule, new JsonapiCore(undefined, undefined, undefined))
2017
).toThrow(new Error('NgxJsonapiModule is already loaded. Import it in the AppModule only'));
2118
});
2219
});

src/package.json

+26
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,31 @@
2727
},
2828
"peerDependencies": {
2929
"@angular/core": "^5.0.0 || ^6.0.0"
30+
},
31+
"jest": {
32+
"setupTestFrameworkScriptFile": "../setup-jest.ts",
33+
"globals": {
34+
"ts-jest": {
35+
"tsConfigFile": "./tsconfig.spec.json"
36+
},
37+
"__TRANSFORM_HTML__": true
38+
},
39+
"transform": {
40+
"^.+\\.(ts|js|html)$": "../node_modules/jest-preset-angular/preprocessor.js"
41+
},
42+
"testMatch": [
43+
"<rootDir>/**/*.spec.ts"
44+
],
45+
"moduleFileExtensions": [
46+
"ts",
47+
"js",
48+
"html",
49+
"json"
50+
],
51+
"mapCoverage": true,
52+
"coveragePathIgnorePatterns": [
53+
"**/node_modules/**",
54+
"**/demo/**"
55+
]
3056
}
3157
}

src/tsconfig.spec.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"sourceMap": true,
4+
"declaration": false,
5+
"moduleResolution": "node",
6+
"emitDecoratorMetadata": true,
7+
"experimentalDecorators": true,
8+
"lib": [
9+
"es2017",
10+
"dom"
11+
],
12+
"outDir": "../out-tsc/spec",
13+
"module": "commonjs",
14+
"target": "es6",
15+
"types": [
16+
"jest",
17+
"node"
18+
],
19+
"baseUrl": ".",
20+
"rootDir": "../"
21+
},
22+
"include": [
23+
"**/*.spec.ts"
24+
]
25+
}

0 commit comments

Comments
 (0)