Skip to content

Commit 60797e5

Browse files
committed
Add test-app package for testing usage of the sendCoverageBatchSize environment variable
1 parent a0589b4 commit 60797e5

File tree

14 files changed

+758
-0
lines changed

14 files changed

+758
-0
lines changed

.circleci/config.yml

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ workflows:
146146
jobname:
147147
- all-files
148148
- backend
149+
- batch-send-coverage
149150
- before-all-visit
150151
- before-each-visit
151152
- cra-e2e-and-ct
@@ -174,6 +175,7 @@ workflows:
174175
- test-code-coverage-plugin
175176
- test-all-files
176177
- test-backend
178+
- test-batch-send-coverage
177179
- test-before-all-visit
178180
- test-before-each-visit
179181
- test-cra-e2e-and-ct
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["istanbul"]
3+
}
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Test Case: Batch Send Coverage
2+
This test app tests that all expected files are covered when using
3+
the `sendCoverageBatchSize` environment variable in the Cypress
4+
configuration file.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const { defineConfig } = require('cypress')
2+
3+
module.exports = defineConfig({
4+
fixturesFolder: false,
5+
env: {
6+
sendCoverageBatchSize: 1
7+
},
8+
e2e: {
9+
setupNodeEvents(on, config) {
10+
return require('./cypress/plugins/index.js')(on, config)
11+
},
12+
baseUrl: 'http://localhost:1234'
13+
}
14+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// <reference types="cypress" />
2+
it('works', () => {
3+
cy.visit('/')
4+
cy.contains('Page body')
5+
6+
cy.window()
7+
.invoke('reverse', 'super')
8+
.should('equal', 'repus')
9+
10+
cy.window()
11+
.invoke('numsTimesTwo', [1, 2, 3])
12+
.should('deep.equal', [2, 4, 6])
13+
14+
cy.window()
15+
.invoke('add', 2, 3)
16+
.should('equal', 5)
17+
18+
cy.window()
19+
.invoke('sub', 5, 2)
20+
.should('equal', 3)
21+
22+
// application's code should be instrumented
23+
cy.window().should('have.property', '__coverage__')
24+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = (on, config) => {
2+
require('@cypress/code-coverage/task')(on, config)
3+
return config
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import '@cypress/code-coverage/support'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require('./commands')
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<body>
2+
Page body
3+
<script src="main.js"></script>
4+
<script src="second.js"></script>
5+
<script src="third.js"></script>
6+
// use functions creates in "main.js"
7+
if (add(2, 3) !== 5) {
8+
throw new Error('wrong addition')
9+
}
10+
if (sub(2, 3) !== -1) {
11+
throw new Error('wrong subtraction')
12+
}
13+
if (reverse('foo') !== 'oof') {
14+
throw new Error('wrong string reverse')
15+
}
16+
</script>
17+
</body>

test-apps/batch-send-coverage/main.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
window.add = (a, b) => a + b
2+
3+
window.sub = (a, b) => a - b

0 commit comments

Comments
 (0)