Skip to content

Commit

Permalink
feat: working test
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Sep 15, 2020
1 parent ccd4442 commit aae6b47
Show file tree
Hide file tree
Showing 5 changed files with 6,004 additions and 220 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -9,6 +9,10 @@ jobs:

- name: Cypress run 🧪
uses: cypress-io/github-action@v2
with:
# run Cypress via this script
# and verify that exactly 3 tests are passing
command: node . run --passing 3

- name: Semantic Release 🚀
uses: cycjimmy/semantic-release-action@v2
Expand Down
12 changes: 12 additions & 0 deletions README.md
Expand Up @@ -2,6 +2,18 @@

> Cypress CLI wrapper where you can specify the total number of expected tests
## Use

Assuming `cypress` has been installed already

```shell
npm i -D cypress-expect # or yarn add -D cypress-expect
# instead of "cypress run ..."
npx cypress-expect run --expect <N> ...
```

Where `N` is the number of total tests expected to pass.

## Debugging

Run this script with environment variable `DEBUG=cypress-expect` to see verbose logs
Expand Down
7 changes: 6 additions & 1 deletion index.js
Expand Up @@ -8,6 +8,7 @@ const cypress = require('cypress')
const debug = require('debug')('cypress-expect')
const arg = require('arg')

// remove all our arguments to let Cypress only deal with its arguments
const args = arg({
'--passing': Number, // number of total passing tests to expect
})
Expand All @@ -21,12 +22,15 @@ if (args['--passing'] < 0) {
}

const parseArguments = async () => {
// remove all our arguments to let Cypress only deal with its arguments
const cliArgs = args._
if (cliArgs[0] !== 'cypress') {
cliArgs.unshift('cypress')
}

if (cliArgs[1] !== 'run') {
cliArgs.splice(1, 0, 'run')
}

debug('parsing Cypress CLI %o', cliArgs)
return await cypress.cli.parseRunArguments(cliArgs)
}
Expand Down Expand Up @@ -60,6 +64,7 @@ parseArguments()
}
})
.catch((e) => {
console.log('error: %s', e.message)
console.error(e)
process.exit(1)
})

0 comments on commit aae6b47

Please sign in to comment.