Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: prepare jest upgrade and ts testing
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Jun 21, 2023
commit f8e697ce4dd28ba8899adacf2fa12e33f60b2194
15 changes: 15 additions & 0 deletions __mocks__/@nextcloud/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { c } from "tar"

export const getCurrentUser = function() {
return {
uid: 'test',
displayName: 'Test',
isAdmin: false,
}
}

export const getRequestToken = function() {
return 'test-token-1234'
}

export const onRequestTokenUpdate = function() {}
1 change: 1 addition & 0 deletions __mocks__/svg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'SvgMock'
File renamed without changes.
5 changes: 5 additions & 0 deletions custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ declare module '*.svg?raw' {
export default content
}

declare module '*.svg' {
const content: any
export default content
}

declare module '*.vue' {
import Vue from 'vue'
export default Vue
Expand Down
42 changes: 26 additions & 16 deletions jest.config.js → jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/**
* @copyright Copyright (c) 2020 Marco Ambrosini <[email protected]>
*
* @author Marco Ambrosini <[email protected]>
Expand All @@ -19,42 +19,52 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
import type { Config } from 'jest'

// TODO: find a way to consolidate this in one place, with webpack.common.js
const ignorePatterns = [
'vue-material-design-icons',
'@juliushaertl',
'tributejs',
'@mdi/svg',
'@nextcloud/vue',
'ansi-regex',
'char-regex',
'splitpanes',
'string-length',
'strip-ansi',
'ansi-regex',
'char-regex',
'tributejs',
'vue-material-design-icons',
]

module.exports = {
testMatch: ['<rootDir>/apps/*/src/**/*.(spec|test).(ts|js)'],
modulePathIgnorePatterns: ["<rootDir>/apps-extra/"],
const config: Config = {
testMatch: ['<rootDir>/**/*.(spec|test).(ts|js)'],
modulePathIgnorePatterns: [
'<rootDir>/apps2/',
'<rootDir>/apps-extra/',
],
transformIgnorePatterns: [
'node_modules/(?!(' + ignorePatterns.join('|') + ')/)',
],
setupFilesAfterEnv: ['<rootDir>/tests/jestSetup.js'],
resetMocks: false,
clearMocks: true,
collectCoverageFrom: [
'<rootDir>/apps/*/src/**/*.{js,vue}',
'<rootDir>/**/*.{js,vue}',
],

setupFilesAfterEnv: ['<rootDir>/__tests__/jest-setup.ts'],

testEnvironment: 'jest-environment-jsdom',
preset: 'ts-jest/presets/js-with-ts',

moduleFileExtensions: [
'js',
'vue',
],
// Allow mocking svg files
moduleDirectories: ['node_modules', '<rootDir>/'],
moduleNameMapper: {
'^.+\\.svg(\\?raw)?$': '<rootDir>/__mocks__/svg.js',
},

transform: {
// process `*.js` files with `babel-jest`
'.*\\.(js)$': 'babel-jest',
'^.+\\.js$': 'babel-jest',
'^.+\\.vue$': '@vue/vue2-jest',
},
}

export default config
Loading