Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run single test as per contributing doc #1065

Closed
cameronbraid opened this issue Jun 23, 2018 · 2 comments
Closed

Unable to run single test as per contributing doc #1065

cameronbraid opened this issue Jun 23, 2018 · 2 comments

Comments

@cameronbraid
Copy link
Contributor

Unable to run a single test as per the https://github.com/marko-js/marko/blob/master/.github/CONTRIBUTING.md doc

In the contributing docs it states that you can run a single test by :

npm run mocha -- --grep=lifecycle

however the mocha script that actually run is :

"mocha": "mocha --timeout 10000 --max-old-space-size=768 ./test/*/*.test.js || exit 1",

And therefore the --grep=lifecycle part gets appended after exit 1 leading to every test being run.

npm prints out the command that is run as :

> mocha --timeout 10000 --max-old-space-size=768 ./test/*/*.test.js || exit 1 "--grep=lifecycle"

I tried creating a new script

"mocha-cli" : "mocha --timeout 10000 --max-old-space-size=768 ./test/*/*.test.js"

However when running that I end up running 0 tests :

cameronbraid@cam-laptop ~/w/marko-fork> npm run mocha-cli -- --grep=lifecycle
                                        
                                        

> [email protected] mocha-cli /Users/cameronbraid/workspace-new/marko-fork
> mocha --timeout 10000 --max-old-space-size=768 "--grep=lifecycle"

  0 passing (2ms)

The only way I was able to target a subset of tests was to change the script to be

"mocha-cli": "mocha --timeout 10000 --max-old-space-size=768",

and then run it passing the test-case.test.js file as the first argument e.g.

cameronbraid@cam-laptop ~/w/marko-fork> npm run mocha-cli test/components-pages/index.test.js

> [email protected] mocha-cli /Users/cameronbraid/workspace-new/marko-fork
> mocha --timeout 10000 --max-old-space-size=768 "test/components-pages/index.test.js"


  components-pages/fixtures
    async-boundaries
      ✓ should initialize components correctly across async boundaries
    await-surround-html
      ✓ should mount components
    component-globals
      ✓ should allow attributes to not be updated
[truncated]
 SUMMARY 

  110 passing (4s)
  3 skipped
  3 failing as expected
  1 unexpectedly failing
@mlrawlings
Copy link
Member

Thanks for pointing this out. This was left over from trying to fix an issue with nyc and mocha (istanbuljs/nyc#798).

#1071 pulled out the jsdom testing harness but also addressed a memory leak in the tests, so this should be less of a concern now. I've updated our tests commands (and the corresponding CONTRIBUTING sections) to simply use npm test and you can now npm test -- --grep=lifecycle.

@cameronbraid
Copy link
Contributor Author

Great - thanks, that works for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants