chore(front): make unit-testing cross-platform

Signed-off-by: Grigorii Shartsev <grigorii.shartsev@nextcloud.com>
This commit is contained in:
Grigorii Shartsev 2023-04-28 23:34:14 +02:00
commit c39f69b41e
4 changed files with 35 additions and 9 deletions

View file

@ -20,6 +20,8 @@
*
*/
const { resolve } = require('node:path')
// TODO: find a way to consolidate this in one place, with webpack.common.js
const ignorePatterns = [
'(vue-material-design-icons)',
@ -64,6 +66,8 @@ module.exports = {
'<rootDir>/src/test-setup.js',
'jest-mock-console/dist/setupTestFramework.js',
],
globalSetup: resolve(__dirname, 'jest.global.setup.js'),
collectCoverageFrom: [
'<rootDir>/src/**/*.{js,vue}',
],
@ -76,14 +80,13 @@ module.exports = {
],
moduleNameMapper: {
'\\.(css|scss)$': '<rootDir>/src/__mocks__/styles.js',
'vendor/tflite/(.*).wasm$': '<rootDir>/src/utils/media/effects/virtual-background/vendor/tflite/$1.js',
},
transform: {
// process `*.js` files with `babel-jest`
'.*\\.(js)$': 'babel-jest',
'^.+\\.vue$': '@vue/vue2-jest',
'src/utils/media/effects/virtual-background/vendor/*': 'jest-transform-stub',
'\\.js$': 'babel-jest',
'\\.vue$': '@vue/vue2-jest',
'\\.tflite$': 'jest-transform-stub',
'\\.(css|scss)$': 'jest-transform-stub',
},
}

24
jest.global.setup.js Normal file
View file

@ -0,0 +1,24 @@
/*
* @copyright Copyright (c) 2023 Grigorii Shartsev <me@shgk.me>
*
* @author Grigorii Shartsev <me@shgk.me>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module.exports = () => {
process.env.TZ = 'UTC'
}

View file

@ -9,9 +9,9 @@
"dev": "webpack --node-env development --progress",
"watch": "webpack --node-env development --progress --watch",
"serve": "webpack serve --node-env development --progress --allowed-hosts all",
"test": "TZ=UTC jest",
"test:watch": "TZ=UTC jest --watch",
"test:coverage": "TZ=UTC jest --coverage",
"test": "jest",
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix",
"stylelint": "stylelint css/*.css css/*.scss src/**/*.scss src/**/*.vue",

View file

@ -1 +0,0 @@
module.exports = {}