0

I'm trying to execute just a subset of my node jasmine tests.

I have a project structure as follows

root
  + server
    + invite
      +specs
        inviteSendSpec.js
        inviteConfirmSpec.js
        .. many more spec files
    + auth 
      +specs
       .. many spec files

I can execute all tests from root by running:

node-jasmine --verbose server/

I'm trying to figure out how to use the -m parameter, so that I can just run the test matching a certain file name pattern.

e.g.

node-jasmine --verbose -m invite server/

should run all tests which contain invite, according to the few examples I've found. But instead it just finds one single test.

If I try to run a similar variation e.g.

node-jasmine --verbose -m send server/

it will find no tests.

What is the correct syntax for selecting a subset of tests?

p.s. I'm running jasmine-node 11.1.0 (so its not the walkdir issue)

AyKarsi
  • 9,435
  • 10
  • 54
  • 92

2 Answers2

2

-m or --match parameter is indeed used for file name matching.

I banged my had against the keyboard for couple of hours, and ended up looking at source for cli.js.

So here is the ticket (cli.js, line 228):

var regExpSpec = new RegExp(match + (matchall ? "" : "spec\\.") + "(" + extensions + ")$", 'i')

Aha!

First, you MUST specify --matchall key, otherwise it will use default "spec" prefix.

Second, there is no way you can specify extensions, they are either js or js|coffee|litcoffee if you use --coffee command line parameter

My test files have unit.js suffix (do not ask why), so I ended up with

cli.js --verbose --matchall --match unit\. --test-dir C:\MyProject\

and it did the job.

Hlefreyr
  • 96
  • 1
  • 3
0

Your file names are right and

from the docs github.com/mhevery/jasmine-node

Note: your specification files must be named as *spec.js, *spec.coffee or *spec.litcoffee, which matches the regular expression /spec.(js|coffee|litcoffee)$/i; otherwise jasmine-node won't find them! For example, sampleSpecs.js is wrong, sampleSpec.js is right.

You just need to run the hole folder:

node-jasmine --verbose server/invite/specs/

node-jasmine --verbose server/auth/specs/

Community
  • 1
  • 1
dpineda
  • 2,401
  • 27
  • 25