Jest tests

This commit is contained in:
ty kayn 2020-04-16 12:34:36 +02:00
parent d9c325a0e9
commit ca5ffdc896
10 changed files with 1555 additions and 712 deletions

View File

@ -3,7 +3,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_style = tab
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

1
.eslintcache Normal file
View File

@ -0,0 +1 @@
[{"/home/tykayn/funky-framadate-front/jest.config.js":"1","/home/tykayn/funky-framadate-front/karma.conf.js":"2"},{"size":167,"mtime":1586876658786,"results":"3","hashOfConfig":"4"},{"size":1581,"mtime":1586876658786,"results":"5","hashOfConfig":"4"},{"filePath":"6","messages":"7","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1q0y9j9",{"filePath":"8","messages":"9","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/home/tykayn/funky-framadate-front/jest.config.js",[],"/home/tykayn/funky-framadate-front/karma.conf.js",["10"],{"ruleId":"11","severity":1,"message":"12","line":5,"column":18,"nodeType":"13","messageId":"14","endLine":5,"endColumn":35},"@typescript-eslint/explicit-function-return-type","Missing return type on function.","FunctionExpression","missingReturnType"]

View File

@ -1,16 +1,39 @@
build:
image: node:12
before_script:
- npm ci
image: weboaks/node-karma-protractor-chrome
stages:
- test
- e2e
cache:
paths:
- node_modules/
test:
stage: test
script:
- npm run build
- npm i
- pkill Xvfb
- npm run test
artifacts:
paths:
- dist/
test:
image: node:12
type: test
before_script:
- npm ci
- coverage/
e2e:
stage: e2e
script:
- npm run test
- npm i
- pkill Xvfb
- npm run e2e
pages:
stage: .post
dependencies:
- test
script:
- mv coverage/ public/
artifacts:
paths:
- public
expire_in: 30 days
only:
- master

View File

@ -89,20 +89,8 @@
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"builder": "@angular-builders/jest:run",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": []
}
},
"lint": {

7
jest.config.js Normal file
View File

@ -0,0 +1,7 @@
// const { defaults } = require('jest-config');
//
// module.exports = {
// verbose: true,
// collectCoverage: true,
// collectCoverageFrom: ['src/**/*.ts'],
// };

View File

@ -1,40 +0,0 @@
// 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-firefox-launcher'),
require('karma-phantomjs-launcher'),
require('karma-coverage'),
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: {
reports : ['html', 'lcovonly'],
fixWebpackSourcePaths: true,
thresholds : {
statements: 80,
lines : 80,
branches : 80,
functions : 80,
},
},
reporters : ['progress', 'kjhtml'],
port : 9876,
colors : true,
logLevel : config.LOG_INFO,
autoWatch : true,
browsers : ['FirefoxHeadless'],
singleRun : true,
restartOnFileChange : true,
});
};

View File

@ -11,7 +11,7 @@
"bld:pkg": "npm run build && npm run package",
"build:demo": "ng build --crossOrigin=anonymous --extractCss=true --progress=true --prod && npm run package",
"build:demobliss": "ng build --crossOrigin=anonymous --extractCss=true --baseHref=https://framadate-api.cipherbliss.com --progress=true --prod && npm run package",
"test": "ng test --code-coverage --watch=false",
"test": "ng test --watch=false",
"lint": "ng lint",
"e2e": "ng e2e",
"format:check": "prettier --list-different \"src/{app,environments,assets}/**/*{.ts,.js,.json,.css,.scss}\"",
@ -55,6 +55,7 @@
"zone.js": "^0.10.3"
},
"devDependencies": {
"@angular-builders/jest": "^9.0.1",
"@angular-devkit/build-angular": "^0.901.1",
"@angular/cli": "^9.0.7",
"@angular/compiler-cli": "^9.1.1",
@ -67,6 +68,7 @@
"@storybook/angular": "^5.3.18",
"@types/jasmine": "^3.5.10",
"@types/jasminewd2": "~2.0.8",
"@types/jest": "^25.2.1",
"@types/node": "^13.11.1",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
@ -78,11 +80,7 @@
"husky": "^4.2.5",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.1",
"karma": "^5.0.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.1",
"karma-jasmine": "~3.1.0",
"karma-jasmine-html-reporter": "^1.5.3",
"jest": "^25.3.0",
"lint-staged": "^10.1.3",
"prettier": "^2.0.4",
"protractor": "~5.4.3",

View File

@ -1,14 +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);

View File

@ -1,9 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": ["jasmine", "node"]
"outDir": "./public/out-tsc/spec",
"module": "commonjs",
"types": ["jest"]
},
"files": ["src/test.ts", "src/polyfills.ts"],
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
"files": ["test.ts", "polyfills.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
}

1867
yarn.lock

File diff suppressed because it is too large Load Diff