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

WSL: in watch mode coverageMap is {} => Unknown% (0/0) #551

Closed
baslr opened this issue Jan 28, 2020 · 2 comments · Fixed by #588
Closed

WSL: in watch mode coverageMap is {} => Unknown% (0/0) #551

baslr opened this issue Jan 28, 2020 · 2 comments · Fixed by #588

Comments

@baslr
Copy link

baslr commented Jan 28, 2020

Environment

  1. node -v: v12.14.1

  2. npm -v: v6.13.6

  3. npm ls jest: [email protected]

  4. your vscode-jest settings if customized:

    • jest: Debug mode [x]
  5. Operating system: WSL: Debian

Prerequisite

  • are you able to run jest test from command line? yes
  • how do you run your tests from command line? npm run test

Steps to Reproduce

clone https://github.com/baslr/node-template while in WSL: Debian
connect with VSCode to the repository, install extension orta.vscode-jest
reload VSCode and run Jest: Toggle Coverage Overlay

Relevant Debug Info

ezgif-6-063799b48bf1

Dev tools
[Extension Host] spawning process with command="/home/user/node-project-template/node_modules/.bin/jest" --testLocationInResults --json --useStderr --outputFile /tmp/jest_runner_node_project_template.json --coverage --no-color --reporters default --reporters "/home/user/.vscode-server/extensions/orta.vscode-jest-3.1.1/out/reporter.js"
[Extension Host] spawning process with command="/home/user/node-project-template/node_modules/.bin/jest" --testLocationInResults --json --useStderr --outputFile /tmp/jest_runner_node_project_template.json --watch --coverage --no-color --reporters default --reporters "/home/user/.vscode-server/extensions/orta.vscode-jest-3.1.1/out/reporter.js"
# cli without watch
~/node-project-template$ "/home/user/node-project-template/node_modules/.bin/jest" --testLocationInResults --json --useStderr --outputFile /tmp/jest_runner_node_project_template.json --coverage --no-color --reporters default --reporters "/home/user/.vs
code-server/extensions/orta.vscode-jest-3.1.1/out/reporter.js"
PASS src/__tests__/app.test.mjs
  test app
    ✓ test mul (2ms)
    ✓ test suqare

onRunStart

=============================== Coverage summary ===============================
Statements   : 100% ( 5/5 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 2/2 )
Lines        : 100% ( 4/4 )
================================================================================
Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.893s, estimated 1s
Ran all test suites.
onRunComplete
Test results written to: ../../../tmp/jest_runner_node_project_template.json

cat /tmp/jest_runner_node_project_template.json
{
  "numFailedTestSuites": 0,
  "numFailedTests": 0,
  "numPassedTestSuites": 1,
  "numPassedTests": 2,
  "numPendingTestSuites": 0,
  "numPendingTests": 0,
  "numRuntimeErrorTestSuites": 0,
  "numTodoTests": 0,
  "numTotalTestSuites": 1,
  "numTotalTests": 2,
  "openHandles": [],
  "snapshot": {
    "added": 0,"d
idUpdate":false,"failure":false,"filesAdded":0,"filesRemoved":0,"filesRemovedList":[],"filesUnmatched":0,"filesUpdated":0,"matched":0,"total":0,"unchecked":0,"uncheckedKeysByFile":[],"unmatched":0,"updated":0},"startTime":1580206509131,"success":true,"testResul
ts":[{"assertionResults":[{"ancestorTitles":["test app"],"failureMessages":[],"fullName":"test app test mul","location":{"column":4,"line":4},"status":"passed","title":"test mul"},{"ancestorTitles":["test app"],"failureMessages":[],"fullName":"test app test suq
are","location":{"column":4,"line":8},"status":"passed","title":"test suqare"}],"endTime":1580206509976,"message":"","name":"/home/user/node-project-template/src/__tests__/app.test.mjs","startTime":1580206509555,"status":"passed","summary":""}],"wasInterrupted": false,
    "coverageMap": {
      "/home/user/node-project-template/src/app.mjs": {
        "path": "/home/user/node-project-template/src/app.mjs",
        "statementMap": {
          "0": {
            "start": {
              "line": 2,
              "column": 19
            },
            "end": {
              "line": 2,
              "column": 34
            }
          },
          "1": {
            "start": {
              "line": 2,
              "column": 29
            },
            "end": {
              "line": 2,"co
lumn":34}},"2":{"start":{"line":4,"column":10},"end":{"line":4,"column":19}},"3":{"start":{"line":6,"column":19},"end":{"line":6,"column":23}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":17}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"star
t":{"line":2,"column":19},"end":{"line":2,"column":20}},"loc":{"start":{"line":2,"column":29},"end":{"line":2,"column":34}},"line":2},"1":{"name":"square","decl":{"start":{"line":9,"column":16},"end":{"line":9,"column":22}},"loc":{"start":{"line":9,"column":29},
              "end": {
                "line": 11,
                "column": 1
              }
            },
            "line": 9
          }
        },
        "branchMap": {},
        "s": {
          "0": 1,
          "1": 1,
          "2": 1,
          "3": 1,
          "4": 1
        },
        "f": {
          "0": 1,
          "1": 1
        },
        "b": {},
        "_coverageSchema": "1a1c01bbd47fc00a2c39e90264f33305004495a9",
        "hash": "1ca9e65386456115c0d0c2d50dd9be238277c325"
      }
    }
  }
# cli with watch
"/home/user/node-project-template/node_modules/.bin/jest" --testLocationInResults --json --useStderr --outputFile /tmp/jest_runner_node_project_template.json --watch --coverage --no-color --reporters default --reporters "/home/
user/.vscode-server/extensions/orta.vscode-jest-3.1.1/out/reporter.js"
PASS src/__tests__/app.test.mjs
  test app
    ✓ test mul (2ms)
    ✓ test suqare

onRunStart

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================
Test Suites: 1 passed, 1 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        0.887s, estimated 1s
Ran all test suites related to changed files.
onRunComplete
Test results written to: ../../../tmp/jest_runner_node_project_template.json

cat /tmp/jest_runner_node_project_template.json
{
  "numFailedTestSuites": 0,
  "numFailedTests": 0,
  "numPassedTestSuites": 1,
  "numPassedTests": 2,
  "numPendingTestSuites": 0,
  "numPendingTests": 0,
  "numRuntimeErrorTestSuites": 0,
  "numTodoTests": 0,
  "numTotalTestSuites": 1,
  "numTotalTests": 2,
  "openHandles": [],
  "snapshot": {
    "added": 0,
    "didUpdate": false,
    "failure": false,
    "filesAdded": 0,
    "filesRemoved": 0,
    "filesRemovedList": [],
    "filesUnmatched": 0,
    "filesUpdated": 0,
    "matched": 0,
    "total": 0,
    "unchecked": 0,
    "uncheckedKeysByFile": [],
    "unmatched": 0,
    "updated": 0
  },
  "startTime": 1580206775917,
  "success": true,
  "testResults": [
    {
      "assertionResults": [
        {
          "ancestorTitles": [
            "test app"
          ],
          "failureMessages": [],
          "fullName": "test app test mul",
          "location": {
            "column": 4,
            "line": 4
          },
          "status": "passed",
          "title": "test mul"
        },
        {
          "ancestorTitles": [
            "test app"
          ],
          "failureMessages": [],
          "fullName": "test app test suqare",
          "location": {
            "column": 4,
            "line": 8
          },
          "status": "passed",
          "title": "test suqare"
        }
      ],
      "endTime": 1580206776775,
      "message": "",
      "name": "/home/user/node-project-template/src/__tests__/app.test.mjs",
      "startTime": 1580206776346,
      "status": "passed",
      "summary": ""
    }
  ],
  "wasInterrupted": false,
  "coverageMap": {}
}

Expected Behavior

visual code coverage and coverage summary should not be Unknown% (0/0)

Actual Behavior

ezgif-6-063799b48bf1

for reference #433 --ci does not help.

@connectdotz
Copy link
Collaborator

thanks for bringing this to our attention, there are a few things I saw here:

  1. this extension doesn't recognize .mjs extension, you won't see any test status indicator for the test file nor coverage stats/state for the source file.
  2. after manually changed the file extension, I saw parse error for the optional-channing syntax that the extension's parser simply does not know how to parse.
  3. during the testing, also discovered the coverage map merge() function didn't work as expected when source code is reduced.
  4. I can't reproduce the Unknown { 100%} error on the mac, not sure if it is WSL specific? did you see the same unknown error when executing the jest command in a terminal? If so then it is probably best to file an issue in jest as it is not specific to vscoe-jest.

to conclude: 1, 2 and 3 are issues we can definitely address within vscode-jest and jest-editor-support; 4 needs more info...

@baslr
Copy link
Author

baslr commented Jan 29, 2020

@connectdotz thank you for your fast response.

When I add a test and try jest with --watch, --watchAll on macOS and WSL: Debian I get:

git diff src/
diff --git a/src/__tests__/app.test.mjs b/src/__tests__/app.test.mjs
index 5be908d..a4a1646 100755
--- a/src/__tests__/app.test.mjs
+++ b/src/__tests__/app.test.mjs
@@ -14,4 +14,9 @@ describe('test app', () => {
         const ret = square(3, 3);
         expect(ret).toBe(36);
     });
+
+    test('test two', () => {
+        const ret = square(3, 3);
+        expect(ret).toBe(36);
+    });


npx jest --watch --coverage
PASS src/__tests__/app.test.mjs
  test app
    ✓ test mul (2ms)
    ✓ test suqare
    ✓ test foo (1ms)
    ✓ test two

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                   
----------|---------|----------|---------|---------|-------------------

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================
Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        1.003s
Ran all test suites related to changed files.


npx jest --watchAll --coverage
PASS src/__tests__/app.test.mjs
  test app
    ✓ test mul (2ms)
    ✓ test suqare
    ✓ test foo
    ✓ test two

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |      100 |     100 |     100 |                   
 app.mjs  |     100 |      100 |     100 |     100 |                   
----------|---------|----------|---------|---------|-------------------

=============================== Coverage summary ===============================
Statements   : 100% ( 6/6 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 2/2 )
Lines        : 100% ( 5/5 )
================================================================================
Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        1.025s
Ran all test suites.

Interestingly --watchAll has coverage summary but --watch has a Unknown coverage summary.
I will report it to the jest team.
Looking forward to get 1, 2, 3 fixed :-)

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

Successfully merging a pull request may close this issue.

3 participants