-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathcombine.cy.js
95 lines (92 loc) · 2.4 KB
/
combine.cy.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/// <reference types="Cypress" />
const { combineNycOptions, defaultNycOptions } = require('../../common-utils')
describe('Combine NYC options', () => {
it('overrides defaults', () => {
const pkgNycOptions = {
extends: '@istanbuljs/nyc-config-typescript',
all: true
}
const combined = combineNycOptions(defaultNycOptions, pkgNycOptions)
cy.wrap(combined).should('deep.equal', {
extends: '@istanbuljs/nyc-config-typescript',
all: true,
'report-dir': './coverage',
reporter: ['lcov', 'clover', 'json', 'json-summary'],
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
excludeAfterRemap: false
})
})
it('allows to specify reporter, but changes to array', () => {
const pkgNycOptions = {
reporter: 'text'
}
const combined = combineNycOptions(defaultNycOptions, pkgNycOptions)
cy.wrap(combined).should('deep.equal', {
'report-dir': './coverage',
reporter: ['text'],
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
excludeAfterRemap: false
})
})
it('combines multiple options', () => {
const pkgNycOptions = {
all: true,
extension: '.js'
}
const nycrc = {
include: ['foo.js']
}
const nycrcJson = {
exclude: ['bar.js'],
reporter: ['json']
}
const nycConfig = {
'report-dir': './report'
}
const combined = combineNycOptions(
defaultNycOptions,
nycrc,
nycrcJson,
nycConfig,
pkgNycOptions
)
cy.wrap(combined).should('deep.equal', {
all: true,
'report-dir': './report',
reporter: ['json'],
extension: ['.js'],
excludeAfterRemap: false,
include: ['foo.js'],
exclude: ['bar.js']
})
})
it('converts exclude to array', () => {
// https://github.com/cypress-io/code-coverage/issues/248
const pkgNycOptions = {
all: true,
extension: '.js'
}
const nycrc = {
include: ['foo.js']
}
const nycrcJson = {
exclude: 'bar.js',
reporter: ['json']
}
const combined = combineNycOptions(
defaultNycOptions,
nycrc,
nycrcJson,
pkgNycOptions
)
cy.wrap(combined).should('deep.equal', {
all: true,
'report-dir': './coverage',
reporter: ['json'],
extension: ['.js'],
excludeAfterRemap: false,
include: ['foo.js'],
exclude: ['bar.js']
})
})
})