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

fix typescript jest test crash #4363

Merged
merged 1 commit into from
Aug 27, 2017

Conversation

connectdotz
Copy link
Contributor

Summary

vscode-jest failed to highlight failed jest tests on editor, due to the packages/jest-test-typescript-parser/test_script_parser.js crash:

TypeError: Cannot read property 'text' of undefined

Basically, test_script_parser.js @line 40 failed to check if element is null before calling element.text.

while (!expectText) {
          expectText = element.text;
          element = element.expression;
}

This would crash if the callable node doesn't have the text portion:

[1,2,3].forEach(n => {...});

Fix is easy and minimal, also added a test case, see below.

Test plan

  • no UI change.
  • added new parser test example: fixures/CallExpressionWithoutText.example
  • added 2 new test cases in fixures/parser_tests.js

test_script_parser.js @line 39 failed to check if element is null before accessing the text property.

```
while (!expectText) {
          expectText = element.text;
          element = element.expression;
        }
```
This would crash if the callable node doesn't have the text portion:

```
[1,2,3].forEach(n => {...});
```
Fix is easy, also added a test case.
@codecov-io
Copy link

Codecov Report

Merging #4363 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4363   +/-   ##
=======================================
  Coverage   55.85%   55.85%           
=======================================
  Files         189      189           
  Lines        6383     6383           
  Branches        6        6           
=======================================
  Hits         3565     3565           
  Misses       2815     2815           
  Partials        3        3
Impacted Files Coverage Δ
...t-test-typescript-parser/src/type_script_parser.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update db4465e...da552a9. Read the comment docs.

@orta
Copy link
Member

orta commented Aug 26, 2017

Perfect - thanks @connectdotz

And thanks for poking me @cpojer 👍

@cpojer cpojer merged commit e4278b3 into jestjs:master Aug 27, 2017
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants