Every time I run npm test --grep "HomePage" it displays a warning message Warning: Cannot find any files matching pattern "HomePage" and runs all the tests despite having a describe with that keyword. You can find it in that repo https://github.com/ThePinger/first-project in /__tests__ /acceptance/home-page.acceptance.ts. So does anyone have a solution to this problem ??
docs/site/Debugging-tests-with-mocha.md.Greetings :wave: to all Hacktoberfest 2020 participants!
Here are few tips 馃憖 to make your start easier, see also #6456.
import statements, we rely on you to find the places needing improvement. Don't worry if you miss some, others will pick them up later. It's perfectly fine to work in small steps, changing only few pages in a single pull request. Baby steps FTW, every little helps!#loopback-contributors channel, you can join our Slack workspace here. IIRC, npm is treating --grep as its own option and does not pass it to the underlying script. As a result, the following command is invoked to run Mocha tests - notice that --grep is not present and therefore Mocha treats HomePage as a name of a file to load:
> [email protected] test /private/tmp/first-project
> lb-mocha --allow-console-logs "dist/__tests__" "HomePage"
You need to add -- before any arguments you want to npm to pass directly to the invoked script.
$ npm test -- --grep "HomePage"
With that change, npm gives both --grep and HomePage arguments to lb-mocha:
> [email protected] test /private/tmp/first-project
> lb-mocha --allow-console-logs "dist/__tests__" "--grep" "HomePage"
It would be great to capture this information in DEVELOPING.md file we create in scaffolded projects, see the template in packages/cli/generators/project/templates/DEVELOPING.md.
Would you @ThePinger like to contribute this improvement yourself? See Contributing code in LoopBack 4 and Submitting a pull request to LoopBack 4 to get started.
@bajtos Well thanks a lot for the good elaboration that worked as expected, and of course I would like to contribute this improvement.
I believe this is covered in the new troubleshooting doc: https://loopback.io/doc/en/lb4/Debugging-tests-with-mocha.html#running-specific-tests
cc @bajtos closing this issue. Feel free to reopen it if necessary.
Most helpful comment
IIRC,
npmis treating--grepas its own option and does not pass it to the underlying script. As a result, the following command is invoked to run Mocha tests - notice that--grepis not present and therefore Mocha treatsHomePageas a name of a file to load:You need to add
--before any arguments you want tonpmto pass directly to the invoked script.With that change,
npmgives both--grepandHomePagearguments tolb-mocha:It would be great to capture this information in
DEVELOPING.mdfile we create in scaffolded projects, see the template in packages/cli/generators/project/templates/DEVELOPING.md.Would you @ThePinger like to contribute this improvement yourself? See Contributing code in LoopBack 4 and Submitting a pull request to LoopBack 4 to get started.