You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which will run ./scripts/mocha-bootload.js first to set expect global:
// ./scripts/mocha-bootload.jsvarchai=require('chai');chai.use(require('dirty-chai'));// use dirty-chai to avoid eslint errorsglobal.expect=chai.expect;
...
Now I can use mocha/chai as global without importing them.
// ./src/__tests__/index.test.js// no any import is neededdescribe('first test',()=>{it('should be passed',()=>{expect(true).to.be.true();})})
But this will raise errors when I run eslint. To make mocha pass eslint, I add "env": {"mocha": true} in the .eslintrc config file:
However, it doesn't support "env": {"chai": true} to tell eslint treat chai as environment variables. How do I do to make it pass eslint (without adding any line in each test files)? By the way, is there any better way to set chia's expect/should/assert to be global?
The text was updated successfully, but these errors were encountered:
I use mocha/chai with eslint/flow.
Currently, I run the tests with an npm script:
which will run
./scripts/mocha-bootload.js
first to setexpect
global:Now I can use
mocha
/chai
as global without importing them.But this will raise errors when I run
eslint
. To make mocha pass eslint, I add"env": {"mocha": true}
in the.eslintrc
config file:However, it doesn't support
"env": {"chai": true}
to telleslint
treatchai
as environment variables. How do I do to make it pass eslint (without adding any line in each test files)? By the way, is there any better way to setchia
's expect/should/assert to be global?The text was updated successfully, but these errors were encountered: