feat: prepare jest coverage support

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ 2023-06-20 12:12:56 +02:00
parent 70ee8de0ab
commit 45ecd55d89
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
6 changed files with 30 additions and 20 deletions

View File

@ -25,8 +25,8 @@ jobs:
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1
id: versions
with:
fallbackNode: '^12'
fallbackNpm: '^6'
fallbackNode: '^16'
fallbackNpm: '^7'
test:
runs-on: ubuntu-latest
@ -47,8 +47,13 @@ jobs:
- name: Install dependencies
run: npm ci
- name: Test
run: npm run test
- name: Test and process coverage
run: npm run test:coverage
- name: Collect coverage
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
with:
files: ./coverage/lcov.info
jsunit:
runs-on: ubuntu-latest

1
.gitignore vendored
View File

@ -154,6 +154,7 @@ Vagrantfile
/config/config-autotest-backup.php
/config/autoconfig.php
clover.xml
/coverage
# Tests - dependencies
tests/acceptance/vendor/

BIN
dist/files-main.js vendored

Binary file not shown.

BIN
dist/files-main.js.map vendored

Binary file not shown.

View File

@ -37,34 +37,37 @@ const ignorePatterns = [
const config: Config = {
testMatch: ['<rootDir>/**/*.(spec|test).(ts|js)'],
modulePathIgnorePatterns: [
'<rootDir>/apps2/',
'<rootDir>/apps-extra/',
],
transformIgnorePatterns: [
'node_modules/(?!(' + ignorePatterns.join('|') + ')/)',
],
clearMocks: true,
collectCoverageFrom: [
'<rootDir>/**/*.{js,vue}',
],
clearMocks: true,
setupFilesAfterEnv: ['<rootDir>/__tests__/jest-setup.ts'],
testEnvironment: 'jest-environment-jsdom',
preset: 'ts-jest/presets/js-with-ts',
// Allow mocking svg files
moduleDirectories: ['node_modules', '<rootDir>/'],
moduleNameMapper: {
'^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js',
},
roots: [
'<rootDir>/__mocks__',
'<rootDir>/__tests__',
'<rootDir>/apps',
'<rootDir>/core',
],
transform: {
// process `*.js` files with `babel-jest`
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': '@vue/vue2-jest',
},
transformIgnorePatterns: [
'node_modules/(?!(' + ignorePatterns.join('|') + ')/)',
],
// Allow mocking svg files
moduleNameMapper: {
'^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js',
},
modulePathIgnorePatterns: [
'<rootDir>/apps2/',
'<rootDir>/apps-extra/',
],
}
export default config

View File

@ -16,6 +16,7 @@
"lint:fix": "eslint 'apps/*/src/**/*.{vue,js}' 'core/src/**/*.{vue,js}' --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"test:jsunit": "karma start tests/karma.config.js --single-run",
"sass": "sass --style compressed --load-path core/css core/css/ $(for cssdir in $(find apps -mindepth 2 -maxdepth 2 -name \"css\"); do if ! $(git check-ignore -q $cssdir); then echo -n \"$cssdir \"; fi; done)",
"sass:watch": "sass --watch --load-path core/css core/css/ $(for cssdir in $(find apps -mindepth 2 -maxdepth 2 -name \"css\"); do if ! $(git check-ignore -q $cssdir); then echo -n \"$cssdir \"; fi; done)",