Closed Bug 1620162 Opened 4 years ago Closed 4 years ago

ESLint jest failures when updating to 23.0.x

Categories

(DevTools :: Debugger, task, P3)

task

Tracking

(firefox81 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: standard8, Assigned: duncangleeddean, Mentored)

Details

(Keywords: good-first-bug)

Attachments

(1 file)

I'm looking at updating our node modules to the latest versions. When I was running through the updates, updating eslint-plugin-jest caused various errors to be reported.

STR:

$ cd mozilla-central
$ npm install --save-exact --save-dev eslint-plugin-jest@23.8.1
$ ./mach eslint devtools/*

Output:

devtools/client/debugger/packages/devtools-reps/src/reps/tests/event.js
  92:3  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)

devtools/client/debugger/packages/devtools-utils/src/tests/network-request.js
  43:7  error  Tests should use Jest‘s exception helpers. Use "expect(() => yourFunction()).toThrow()" for synchronous tests, or "await expect(yourFunction()).rejects.toThrow()" for async tests  jest/no-try-expect (eslint)

devtools/client/debugger/src/utils/tests/quick-open.spec.js
  12:24  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)
  27:28  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)

devtools/client/debugger/src/utils/tests/wasm.spec.js
  60:5  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)

devtools/client/debugger/src/workers/parser/tests/framework.spec.js
  16:5  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)

devtools/client/debugger/src/workers/parser/tests/getScopes.spec.js
  24:7  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)

devtools/client/debugger/src/workers/parser/tests/getSymbols.spec.js
  19:5  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)

devtools/client/debugger/src/workers/parser/utils/tests/ast.spec.js
  34:5  error  Expect must be inside of a test block.  jest/no-standalone-expect (eslint)
Component: General → Debugger
Keywords: good-first-bug
Priority: -- → P3

Hey 👋

I’m currently fixing these lint issues. Will submit a patch tomorrow.

Great, thanks! Assigning to you.

@bomsy, could you please help with the review here?

Honza

Assignee: nobody → duncangleeddean
Status: NEW → ASSIGNED
Flags: needinfo?(hmanilla)

Sure! Thanks Honza.

Mentor: hmanilla
Flags: needinfo?(hmanilla)

Hi @bomsy :)

Just maybe a question on whether standalone expects should be allowed or not? Are we going to be happy with these checks or must I disable that particular rule?

I've been fixing the issues to comply but maybe that's not the way we wish to go :)

Flags: needinfo?(hmanilla)

It looks like the rule jest/no-standalone-expect is also not compatible with jest-in-case's cases. Related issue on GitHub. Which leads me to think that this particular rule might need to be disabled for now unless it's just disabled in the files using cases .

Hi Duncan,
Yes i think we can turn the rule off in the eslintrc file and add a comment detailing the reason why and links to any useful documentation?

Flags: needinfo?(hmanilla)

Currently the jest/no-standalone-expect rule needs to be disabled for jest-in-case cases blocks as it is not compatible.

Pushed by hmanilla@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/df0fd723b0ae
Upgrade eslint-plugin-jest and fix new lint errors. r=bomsy,Standard8
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: