Skip to content

The --cwd option breaks instrumentation on Windows #1310

Description

@elliot-nelson

Link to bug demonstration repository

https://github.com/elliot-nelson/nyc-bug-demo

Expected Behavior

Running nyc --cwd spec jasmine should instrument the specs run, and produce a coverage report:

1 spec, 0 failures
Finished in 0.023 seconds
Randomized with seed 40333 (jasmine --random=true --seed=40333)
---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
---------------|---------|----------|---------|---------|-------------------
All files      |     100 |      100 |     100 |     100 |                   
 index-spec.js |     100 |      100 |     100 |     100 |                   
---------------|---------|----------|---------|---------|-------------------

Observed Behavior

Adding the --cwd option removes all instrumentation:

1 spec, 0 failures
Finished in 0.017 seconds
Randomized with seed 50629 (jasmine --random=true --seed=50629)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------

Troubleshooting steps

  • Issue occurs only on Windows (the --cwd flag works as expected on MacOS/Linux)
  • Issue does not occur in Windows using nyc@14.1.1 (--cwd flag works as expected)
  • Suspecting the issue is with jasmine, I tried modifying the the "spec_dir" setting in spec/support/jasmine.json - this didn't work (jasmine is running the right files, those files just aren't instrumented).

Environment Information

npx: installed 1 in 1.869s

  System:
    OS: Windows Server 2012 6.3.9600
    CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
    Memory: 5.63 GB / 8.00 GB
  Binaries:
    Node: 8.15.0 - c:\nodejs\node.EXE
    npm: 6.4.1 - c:\nodejs\npm.CMD
  npmPackages:
    nyc: ^15.0.1 => 15.0.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions