Skip to content

Commit bd09462

Browse files
authored
fix: improve spec filtering (#171)
* fix: better unit coverage filter * add to CI * fix path
1 parent 732001d commit bd09462

File tree

14 files changed

+246
-4
lines changed

14 files changed

+246
-4
lines changed

.circleci/config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,33 @@ workflows:
168168
command: npm run coverage:check
169169
working_directory: examples/ts-example
170170

171+
- cypress/run:
172+
attach-workspace: true
173+
name: example-same-folder
174+
requires:
175+
- cypress/install
176+
# there are no jobs to follow this one
177+
# so no need to save the workspace files (saves time)
178+
no-workspace: true
179+
command: npx cypress run --project examples/same-folder
180+
# store screenshots and videos
181+
store_artifacts: true
182+
post-steps:
183+
- run: cat examples/same-folder/.nyc_output/out.json
184+
# store the created coverage report folder
185+
# you can click on it in the CircleCI UI
186+
# to see live static HTML site
187+
- store_artifacts:
188+
path: examples/same-folder/coverage
189+
# make sure the examples captures 100% of code
190+
- run:
191+
command: npx nyc report --check-coverage true --lines 100
192+
working_directory: examples/same-folder
193+
# how to fail if the specific file coverage is not found?!
194+
- run:
195+
command: npx nyc report --check-coverage true --lines 100 --include unit-utils.js
196+
working_directory: examples/same-folder
197+
171198
- publish:
172199
filters:
173200
branches:
@@ -181,3 +208,4 @@ workflows:
181208
- example-before-each-visit
182209
- example-before-all-visit
183210
- example-ts-example
211+
- example-same-folder

examples/same-folder/.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["istanbul"]
3+
}

examples/same-folder/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# example: same-folder
2+
3+
Check if test files are correctly filtered out

examples/same-folder/cypress.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"integrationFolder": ".",
3+
"testFiles": "**/spec.js",
4+
"supportFile": "support.js",
5+
"pluginsFile": "plugins.js"
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

examples/same-folder/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<body>
2+
Page body
3+
<script src="main-instrumented.js"></script>
4+
</body>

examples/same-folder/main-instrumented.js

Lines changed: 146 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/same-folder/main.js

Lines changed: 3 additions & 0 deletions
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

examples/same-folder/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "example-same-folder",
3+
"description": "Check if test files are correctly filtered out",
4+
"devDependencies": {},
5+
"scripts": {
6+
"cy:open": "../../node_modules/.bin/cypress open"
7+
}
8+
}

examples/same-folder/plugins.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = (on, config) => {
2+
on('task', require('../../task'))
3+
on('file:preprocessor', require('../../use-babelrc'))
4+
}

0 commit comments

Comments
 (0)