test: migrate from karma to jest

This commit is contained in:
4gray committed 2020-10-06 20:34:19 +02:00
1 parent ec8871189a
commit f778e1d9d8
8 files changed
+4949 -111

No files matched your search

+1 -21
View File
@@ -104,26 +104,6 @@
"browserTarget": "angular-electron:build"
}
},
"test": {
"builder": "@angular-builders/custom-webpack:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills-test.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"scripts": [],
"styles": [
"src/styles.scss"
],
"assets": [
"src/assets"
],
"customWebpackConfig": {
"path": "./angular.webpack.js",
"target": "electron-renderer"
}
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
@@ -168,4 +148,4 @@
"prefix": "app"
}
}
}
}
+4918 -1
View File
File diff suppressed because it is too large. Load diff
+18 -1
View File
@@ -62,6 +62,7 @@
"@semantic-release/git": "9.0.0",
"@types/jasmine": "3.5.11",
"@types/jasminewd2": "2.0.8",
"@types/jest": "26.0.14",
"@types/mocha": "7.0.2",
"@types/node": "12.12.6",
"@typescript-eslint/eslint-plugin": "3.6.0",
@@ -78,12 +79,15 @@
"eslint-plugin-import": "2.22.0",
"jasmine-core": "3.5.0",
"jasmine-spec-reporter": "5.0.2",
"jest": "26.4.2",
"jest-preset-angular": "8.3.1",
"karma": "5.1.0",
"karma-coverage-istanbul-reporter": "3.0.3",
"karma-electron": "6.3.0",
"karma-jasmine": "3.3.1",
"karma-jasmine-html-reporter": "1.5.4",
"mocha": "7.2.0",
"ng-mocks": "10.1.3",
"npm-run-all": "4.1.5",
"rxjs": "6.6.0",
"semantic-release": "17.1.1",
@@ -121,5 +125,18 @@
"ngx-uploader": "10.0.0",
"uuid": "8.3.0",
"video-js": "0.7.0"
},
"jest": {
"preset": "jest-preset-angular",
"setupFilesAfterEnv": [
"<rootDir>/src/setupJest.ts"
],
"testMatch": [
"**/+(*.)+(spec|test).+(ts)?(x)"
],
"coverageReporters": [
"html",
"lcov"
]
}
}
}
-44
View File
@@ -1,44 +0,0 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-electron'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: ['AngularElectron'],
customLaunchers: {
AngularElectron: {
base: 'Electron',
flags: [
'--remote-debugging-port=9222'
],
browserWindowOptions: {
webPreferences: {
nodeIntegration: true,
nodeIntegrationInSubFrames: true,
allowRunningInsecureContent: true
}
}
}
}
});
};
+1
View File
@@ -0,0 +1 @@
import 'jest-preset-angular';
-20
View File
@@ -1,20 +0,0 @@
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
-24
View File
@@ -1,24 +0,0 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills-test.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
],
"exclude": [
"dist",
"release",
"node_modules"
]
}
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"baseUrl": "./",
"types": ["jest", "node"],
"experimentalDecorators": true
},
"files": ["src/polyfills.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
}