-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathjustInTimeCompile_spec.ts
More file actions
75 lines (63 loc) · 2.78 KB
/
justInTimeCompile_spec.ts
File metadata and controls
75 lines (63 loc) · 2.78 KB
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
import systemTests from '../lib/system-tests'
// original source code https://github.com/lodash/lodash/issues/2459#issuecomment-230255219
const getAllMatches = (source, regex) => {
const matches = []
source.replace(regex, function () {
matches.push({
match: arguments[0],
offset: arguments[arguments.length - 2],
groups: Array.prototype.slice.call(arguments, 1, -2),
})
return arguments[0]
})
return matches
}
describe('component testing: justInTimeCompile', function () {
systemTests.setup()
// makes sure justInTimeCompile=true has no affect on how vite compiles files.
systemTests.it('vite@5', {
project: 'justInTimeCompile/vite',
testingType: 'component',
browser: 'electron',
expectedExitCode: 0,
onRun: async (exec) => {
const { stderr } = await exec({
processEnv: {
// print debug logs from @cypress/vite-dev-server to see how many times specs are updated
DEBUG: 'cypress:vite*',
},
})
const serverPortRegex = /Successfully launched the vite server on port 5173/g
const componentsCompiledSeparatelyRegex = /dev\-server\:secs\:changed\: src\/Component\-[1-3]\.cy\.jsx/g
const totalServersSamePort = getAllMatches(stderr, serverPortRegex).length
const totalComponentsCompiledSeparately = getAllMatches(stderr, componentsCompiledSeparatelyRegex).length
// expect 1 server to be created
expect(totalServersSamePort).to.equal(1)
// expect each component to be compiled all together (no JIT support for vite)
expect(totalComponentsCompiledSeparately).to.equal(0)
},
})
systemTests.it('webpack@5', {
project: 'justInTimeCompile/webpack',
testingType: 'component',
browser: 'electron',
expectedExitCode: 0,
onRun: async (exec) => {
const { stderr } = await exec({
processEnv: {
// print debug logs from @cypress/webpack-dev-server to see how many times specs are updated
DEBUG: 'cypress:webpack*',
},
})
const serverPortRegex = /Component testing webpack server 5 started on port 8080/g
const componentsCompiledSeparatelyRegex = /justInTimeCompile\/webpack\/src\/Component\-[1-3].cy.jsx/g
const totalServersSamePort = getAllMatches(stderr, serverPortRegex).length
const totalComponentsCompiledSeparately = getAllMatches(stderr, componentsCompiledSeparatelyRegex).length
// expect 1 server to be created
expect(totalServersSamePort).to.equal(1)
// expect each component compiled individually (3 occurrences total, the first occurs twice due to file writes)
// sometimes, the first output does not get logged. This is not of concern, hence the greaterThan assertion
expect(totalComponentsCompiledSeparately).to.be.greaterThan(2)
},
})
})