Cleanup jest config (#2959)

Some small cleanups with regards to jest
- call jest directly (nyc is integrated in jest these days)
- move jest config into seperate file so we dont clutter up the
package.json
- remove empty test file for newsletter-unit-tests
- update dependencies that touch jest
- try out v8 as coverageProvider

Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
Veeck 2022-10-28 20:57:08 +02:00 committed by GitHub
parent c191ff0032
commit f79d3f007d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 694 additions and 1649 deletions

1
.gitignore vendored
View File

@ -16,7 +16,6 @@ vendor/node_modules/**/*
jspm_modules jspm_modules
.npm .npm
.node_repl_history .node_repl_history
.nyc_output/
# Visual Studio Code ignoramuses. # Visual Studio Code ignoramuses.
.vscode/ .vscode/

View File

@ -1,4 +1,3 @@
/config /config
/coverage /coverage
.nyc_output
package-lock.json package-lock.json

View File

@ -22,7 +22,7 @@ Special thanks to: @rejas, @sdetweil
### Updated ### Updated
- Cleaned up test directory - Cleaned up test directory (#2937) and jest config (#2959)
- Wait for all modules to start before declaring the system ready (#2487) - Wait for all modules to start before declaring the system ready (#2487)
- Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests - Updated e2e tests (moved `done()` in helper functions) and use es6 syntax in all tests
- Updated da translation - Updated da translation

32
jest.config.js Normal file
View File

@ -0,0 +1,32 @@
module.exports = async () => {
return {
verbose: true,
testTimeout: 20000,
testSequencer: "<rootDir>/tests/configs/test_sequencer.js",
projects: [
{
displayName: "unit",
moduleNameMapper: {
logger: "<rootDir>/js/logger.js"
},
testMatch: ["**/tests/unit/**/*.[jt]s?(x)"],
testPathIgnorePatterns: ["<rootDir>/tests/unit/mocks"]
},
{
displayName: "electron",
testMatch: ["**/tests/electron/**/*.[jt]s?(x)"],
testPathIgnorePatterns: ["<rootDir>/tests/electron/helpers/"]
},
{
displayName: "e2e",
setupFilesAfterEnv: ["<rootDir>/tests/e2e/helpers/mock-console.js"],
testMatch: ["**/tests/e2e/**/*.[jt]s?(x)"],
modulePaths: ["<rootDir>/js/"],
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers/", "<rootDir>/tests/e2e/mocks"]
}
],
collectCoverageFrom: ["./clientonly/**/*.js", "./js/**/*.js", "./modules/**/*.js", "./serveronly/**/*.js"],
coverageReporters: ["lcov", "text"],
coverageProvider: "v8"
};
};

2239
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
"install-fonts": "echo \"Installing fonts ...\n\" && cd fonts && npm install --loglevel=error --no-audit --no-fund --no-update-notifier", "install-fonts": "echo \"Installing fonts ...\n\" && cd fonts && npm install --loglevel=error --no-audit --no-fund --no-update-notifier",
"postinstall": "npm run install-vendor && npm run install-fonts && echo \"MagicMirror² installation finished successfully! \n\"", "postinstall": "npm run install-vendor && npm run install-fonts && echo \"MagicMirror² installation finished successfully! \n\"",
"test": "NODE_ENV=test jest -i --forceExit", "test": "NODE_ENV=test jest -i --forceExit",
"test:coverage": "NODE_ENV=test nyc --reporter=lcov --reporter=text jest -i --forceExit", "test:coverage": "NODE_ENV=test jest --coverage -i --forceExit",
"test:electron": "NODE_ENV=test jest --selectProjects electron -i --forceExit", "test:electron": "NODE_ENV=test jest --selectProjects electron -i --forceExit",
"test:e2e": "NODE_ENV=test jest --selectProjects e2e -i --forceExit", "test:e2e": "NODE_ENV=test jest --selectProjects e2e -i --forceExit",
"test:unit": "NODE_ENV=test jest --selectProjects unit -i --forceExit", "test:unit": "NODE_ENV=test jest --selectProjects unit -i --forceExit",
@ -50,16 +50,15 @@
"homepage": "https://magicmirror.builders", "homepage": "https://magicmirror.builders",
"devDependencies": { "devDependencies": {
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-jest": "^27.1.1", "eslint-plugin-jest": "^27.1.3",
"eslint-plugin-jsdoc": "^39.3.6", "eslint-plugin-jsdoc": "^39.3.6",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"express-basic-auth": "^1.2.1", "express-basic-auth": "^1.2.1",
"husky": "^8.0.1", "husky": "^8.0.1",
"jest": "^29.1.2", "jest": "^29.2.2",
"jsdom": "^20.0.1", "jsdom": "^20.0.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"nyc": "^15.1.0", "playwright": "^1.27.1",
"playwright": "^1.26.1",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"pretty-quick": "^3.1.3", "pretty-quick": "^3.1.3",
"sinon": "^14.0.1", "sinon": "^14.0.1",
@ -96,49 +95,5 @@
}, },
"engines": { "engines": {
"node": ">=14" "node": ">=14"
},
"jest": {
"verbose": true,
"testTimeout": 20000,
"testSequencer": "<rootDir>/tests/configs/test_sequencer.js",
"projects": [
{
"displayName": "unit",
"moduleNameMapper": {
"logger": "<rootDir>/js/logger.js"
},
"testMatch": [
"**/tests/unit/**/*.[jt]s?(x)"
],
"testPathIgnorePatterns": [
"<rootDir>/tests/unit/mocks"
]
},
{
"displayName": "electron",
"testMatch": [
"**/tests/electron/**/*.[jt]s?(x)"
],
"testPathIgnorePatterns": [
"<rootDir>/tests/electron/helpers/"
]
},
{
"displayName": "e2e",
"setupFilesAfterEnv": [
"<rootDir>/tests/e2e/helpers/mock-console.js"
],
"testMatch": [
"**/tests/e2e/**/*.[jt]s?(x)"
],
"modulePaths": [
"<rootDir>/js/"
],
"testPathIgnorePatterns": [
"<rootDir>/tests/e2e/helpers/",
"<rootDir>/tests/e2e/mocks"
]
}
]
} }
} }

View File

@ -1,15 +0,0 @@
describe("Functions into modules/default/newsfeed/newsfeed.js", () => {
// Fake for use by newsletter.js
Module = {};
Module.definitions = {};
Module.register = (name, moduleDefinition) => {
Module.definitions[name] = moduleDefinition;
};
beforeAll(() => {
// load newsfeed.js
require("../../../modules/default/newsfeed/newsfeed.js");
});
test.skip("skip", () => {});
});