diff --git a/.circleci/config.yml b/.circleci/config.yml index a097f80c..b90df468 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -168,6 +168,33 @@ workflows: command: npm run coverage:check working_directory: examples/ts-example + - cypress/run: + attach-workspace: true + name: example-same-folder + requires: + - cypress/install + # there are no jobs to follow this one + # so no need to save the workspace files (saves time) + no-workspace: true + command: npx cypress run --project examples/same-folder + # store screenshots and videos + store_artifacts: true + post-steps: + - run: cat examples/same-folder/.nyc_output/out.json + # store the created coverage report folder + # you can click on it in the CircleCI UI + # to see live static HTML site + - store_artifacts: + path: examples/same-folder/coverage + # make sure the examples captures 100% of code + - run: + command: npx nyc report --check-coverage true --lines 100 + working_directory: examples/same-folder + # how to fail if the specific file coverage is not found?! + - run: + command: npx nyc report --check-coverage true --lines 100 --include unit-utils.js + working_directory: examples/same-folder + - publish: filters: branches: @@ -181,3 +208,4 @@ workflows: - example-before-each-visit - example-before-all-visit - example-ts-example + - example-same-folder diff --git a/examples/same-folder/.babelrc b/examples/same-folder/.babelrc new file mode 100644 index 00000000..7a016cf8 --- /dev/null +++ b/examples/same-folder/.babelrc @@ -0,0 +1,3 @@ +{ + "plugins": ["istanbul"] +} diff --git a/examples/same-folder/README.md b/examples/same-folder/README.md new file mode 100644 index 00000000..7790124b --- /dev/null +++ b/examples/same-folder/README.md @@ -0,0 +1,3 @@ +# example: same-folder + +Check if test files are correctly filtered out diff --git a/examples/same-folder/cypress.json b/examples/same-folder/cypress.json new file mode 100644 index 00000000..d1d616ad --- /dev/null +++ b/examples/same-folder/cypress.json @@ -0,0 +1,6 @@ +{ + "integrationFolder": ".", + "testFiles": "**/spec.js", + "supportFile": "support.js", + "pluginsFile": "plugins.js" +} diff --git a/examples/same-folder/cypress/fixtures/example.json b/examples/same-folder/cypress/fixtures/example.json new file mode 100644 index 00000000..da18d935 --- /dev/null +++ b/examples/same-folder/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} \ No newline at end of file diff --git a/examples/same-folder/index.html b/examples/same-folder/index.html new file mode 100644 index 00000000..b6691c8a --- /dev/null +++ b/examples/same-folder/index.html @@ -0,0 +1,4 @@ +
+ Page body + + diff --git a/examples/same-folder/main-instrumented.js b/examples/same-folder/main-instrumented.js new file mode 100644 index 00000000..0550e9bb --- /dev/null +++ b/examples/same-folder/main-instrumented.js @@ -0,0 +1,146 @@ +function cov_6k5v991cn() { + var path = 'main.js' + var hash = 'd384017ecd51a8d90283ba0dec593332209519de' + var global = new Function('return this')() + var gcv = '__coverage__' + var coverageData = { + path: 'main.js', + statementMap: { + '0': { + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 28 + } + }, + '1': { + start: { + line: 1, + column: 23 + }, + end: { + line: 1, + column: 28 + } + }, + '2': { + start: { + line: 3, + column: 0 + }, + end: { + line: 3, + column: 28 + } + }, + '3': { + start: { + line: 3, + column: 23 + }, + end: { + line: 3, + column: 28 + } + } + }, + fnMap: { + '0': { + name: '(anonymous_0)', + decl: { + start: { + line: 1, + column: 13 + }, + end: { + line: 1, + column: 14 + } + }, + loc: { + start: { + line: 1, + column: 23 + }, + end: { + line: 1, + column: 28 + } + }, + line: 1 + }, + '1': { + name: '(anonymous_1)', + decl: { + start: { + line: 3, + column: 13 + }, + end: { + line: 3, + column: 14 + } + }, + loc: { + start: { + line: 3, + column: 23 + }, + end: { + line: 3, + column: 28 + } + }, + line: 3 + } + }, + branchMap: {}, + s: { + '0': 0, + '1': 0, + '2': 0, + '3': 0 + }, + f: { + '0': 0, + '1': 0 + }, + b: {}, + _coverageSchema: '1a1c01bbd47fc00a2c39e90264f33305004495a9', + hash: 'd384017ecd51a8d90283ba0dec593332209519de' + } + var coverage = global[gcv] || (global[gcv] = {}) + + if (!coverage[path] || coverage[path].hash !== hash) { + coverage[path] = coverageData + } + + var actualCoverage = coverage[path] + + cov_6k5v991cn = function() { + return actualCoverage + } + + return actualCoverage +} + +cov_6k5v991cn() +cov_6k5v991cn().s[0]++ + +window.add = (a, b) => { + cov_6k5v991cn().f[0]++ + cov_6k5v991cn().s[1]++ + return a + b +} + +cov_6k5v991cn().s[2]++ + +window.sub = (a, b) => { + cov_6k5v991cn().f[1]++ + cov_6k5v991cn().s[3]++ + return a - b +} +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm1haW4uanMiXSwibmFtZXMiOlsid2luZG93IiwiYWRkIiwiYSIsImIiLCJzdWIiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFBQSxNQUFNLENBQUNDLEdBQVAsR0FBYSxDQUFDQyxDQUFELEVBQUlDLENBQUosS0FBVTtBQUFBO0FBQUE7QUFBQSxTQUFBRCxDQUFDLEdBQUdDLENBQUo7QUFBSyxDQUE1Qjs7OztBQUVBSCxNQUFNLENBQUNJLEdBQVAsR0FBYSxDQUFDRixDQUFELEVBQUlDLENBQUosS0FBVTtBQUFBO0FBQUE7QUFBQSxTQUFBRCxDQUFDLEdBQUdDLENBQUo7QUFBSyxDQUE1QiIsInNvdXJjZXNDb250ZW50IjpbIndpbmRvdy5hZGQgPSAoYSwgYikgPT4gYSArIGJcblxud2luZG93LnN1YiA9IChhLCBiKSA9PiBhIC0gYlxuIl19 diff --git a/examples/same-folder/main.js b/examples/same-folder/main.js new file mode 100644 index 00000000..5dd69be2 --- /dev/null +++ b/examples/same-folder/main.js @@ -0,0 +1,3 @@ +window.add = (a, b) => a + b + +window.sub = (a, b) => a - b diff --git a/examples/same-folder/package.json b/examples/same-folder/package.json new file mode 100644 index 00000000..9f400043 --- /dev/null +++ b/examples/same-folder/package.json @@ -0,0 +1,8 @@ +{ + "name": "example-same-folder", + "description": "Check if test files are correctly filtered out", + "devDependencies": {}, + "scripts": { + "cy:open": "../../node_modules/.bin/cypress open" + } +} diff --git a/examples/same-folder/plugins.js b/examples/same-folder/plugins.js new file mode 100644 index 00000000..723dd9e1 --- /dev/null +++ b/examples/same-folder/plugins.js @@ -0,0 +1,4 @@ +module.exports = (on, config) => { + on('task', require('../../task')) + on('file:preprocessor', require('../../use-babelrc')) +} diff --git a/examples/same-folder/spec.js b/examples/same-folder/spec.js new file mode 100644 index 00000000..6c74ecb6 --- /dev/null +++ b/examples/same-folder/spec.js @@ -0,0 +1,26 @@ +///