forked from technowledgy/vue-h5p
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
57 lines (55 loc) · 1.34 KB
/
jest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { existsSync } from 'fs'
import path from 'path'
import { ResourceLoader } from 'jsdom'
class LocalFileLoader extends ResourceLoader {
fetch (url, options) {
const localPath = url.replace('http://localhost', path.join(path.dirname(import.meta.url), 'tests', 'mocks'))
if (existsSync(localPath)) {
return super.fetch(localPath, options)
} else {
return super.fetch(path.join(path.dirname(import.meta.url), 'tests', 'mocks', 'empty'), options)
}
}
}
export default {
clearMocks: true,
collectCoverage: true,
collectCoverageFrom: [
'<rootDir>/src/**'
],
coverageProvider: 'v8',
coverageReporters: [
'lcov',
'text-summary'
],
moduleFileExtensions: [
'js'
],
moduleNameMapper: {
'^../frame/(.*)\\?raw$': '<rootDir>/frame/$1',
'^@/(.*)$': '<rootDir>/src/$1'
},
setupFilesAfterEnv: [
'<rootDir>/tests/setup.js'
],
snapshotSerializers: [
'jest-serializer-vue'
],
testEnvironment: 'jsdom',
testEnvironmentOptions: {
resources: new LocalFileLoader(),
runScripts: 'dangerously'
},
testMatch: [
'**/tests/unit/**/*.spec.js'
],
transform: {
'/frame/': '<rootDir>/jest-raw-loader.js',
'^.+\\.vue$': '@vue/vue2-jest',
'^.+\\.js$': 'babel-jest'
},
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname'
]
}