Commit 89e6267b authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Add jest as test runner

parent 7ff3c75a
Pipeline #137551 failed with stages
in 11 minutes and 45 seconds
......@@ -47,5 +47,6 @@ Thumbs.db
# reports (custom)
/reports
junit.xml
/local
......@@ -57,16 +57,16 @@ prettier:
unittest:
stage: test
script: npm -s run test -- --codeCoverage --progress=false --watch=false --browsers=ChromeHeadlessCI --reporters junit,dots
script: npm -s run test -- --coverage --reporters="default" --reporters="jest-junit"
artifacts:
name: '$CI_COMMIT_REF_SLUG-$CI_JOB_NAME'
when: always
paths:
- 'coverage/'
- 'reports/TESTS-*.xml'
- 'junit.xml'
reports:
cobertura: 'coverage/bmdl-modeler/cobertura-coverage.xml'
junit: 'reports/TESTS-*.xml'
cobertura: 'coverage/cobertura-coverage.xml'
junit: 'junit.xml'
expire_in: 1 week
dependencies: []
......
module.exports = {
// angular specific
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
// coverage
coverageDirectory: 'coverage',
coverageReporters: ['cobertura', 'html', 'text'],
};
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-junit-reporter'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/bmdl-modeler'),
reports: ['html', 'lcovonly', 'text-summary', 'cobertura'],
fixWebpackSourcePaths: true,
},
reporters: ['progress', 'kjhtml'],
junitReporter: {
outputDir: 'reports',
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
// https://angular.io/guide/testing#configure-cli-for-ci-testing-in-chrome
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
},
singleRun: false,
restartOnFileChange: true,
});
};
This diff is collapsed.
......@@ -6,7 +6,7 @@
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"test": "jest",
"lint": "ng lint",
"style": "npx prettier --check .",
"e2e": "ng e2e",
......@@ -53,6 +53,7 @@
"@ngneat/spectator": "^8.0.2",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "^2.0.10",
"@types/jest": "^26.0.24",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "4.28.2",
"@typescript-eslint/parser": "4.28.2",
......@@ -61,12 +62,9 @@
"jasmine-core": "~3.6.0",
"jasmine-reporters": "^2.4.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.4",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"karma-junit-reporter": "^2.0.1",
"jest": "^27.0.6",
"jest-junit": "^12.2.0",
"jest-preset-angular": "^9.0.5",
"ng-mocks": "^12.4.0",
"prettier": "2.3.2",
"protractor": "~7.0.0",
......
import 'jest-preset-angular/setup-jest';
function (doc) {
var featureMap = {};
var featureStack = [];
if(doc.features) {
featureStack = doc.features;
}
while(featureStack.length > 0){
var f = featureStack.pop();
featureMap[f.id] = f.name;
for(var i = 0; i < f.features.length; i++){
featureStack.push(f.features[f.features.length - 1 -i]);
}
}
emit(doc._id, featureMap);
}
\ No newline at end of file
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/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);
......@@ -2,8 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": ["jasmine", "node"]
"types": ["jest"]
},
"files": ["src/test.ts", "src/polyfills.ts"],
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment