webdriverio: @wdio/mocha-framework@6.10.6 introduces TypeScript errors

Environment (please complete the following information):

  • WebdriverIO version: 6.10.11
  • Mode: standalone
  • If WDIO Testrunner, running sync/async: async
  • Node.js version: v12.16.2
  • NPM version: 6.14.8
  • Additional wdio packages used (if applicable):

Describe the bug @wdio/mocha-framework@6.10.6 causes the following TypeScript errors via @types/jest. I tried downgrading @types/jest, but the same errors occurred. They only went away when downgrading the @wdio/mocha-framework to version 6.10.4.

Seems like after this version was when @types/mocha was added.

I don’t have a simple reproducible way to showcase the error right now. I just have to downgrade to the version that worked before.

error messages
$ ./node_modules/.bin/tsc -p etc
node_modules/@types/mocha/index.d.ts:2581:13 - error TS2403: Subsequent variable declarations must have the same type.  Variable 'beforeEach' must be of type 'Lifecycle', but here has type 'HookFunction'.

2581 declare var beforeEach: Mocha.HookFunction; ~~~~~~~~~~

node_modules/@types/jest/index.d.ts:34:13 34 declare var beforeEach: jest.Lifecycle; ~~~~~~~~~~ ‘beforeEach’ was also declared here.

node_modules/@types/mocha/index.d.ts:2599:13 - error TS2403: Subsequent variable declarations must have the same type. Variable ‘afterEach’ must be of type ‘Lifecycle’, but here has type ‘HookFunction’.

2599 declare var afterEach: Mocha.HookFunction; ~~~~~~~~~

node_modules/@types/jest/index.d.ts:36:13 36 declare var afterEach: jest.Lifecycle; ~~~~~~~~~ ‘afterEach’ was also declared here.

node_modules/@types/mocha/index.d.ts:2615:13 - error TS2403: Subsequent variable declarations must have the same type. Variable ‘describe’ must be of type ‘Describe’, but here has type ‘SuiteFunction’.

2615 declare var describe: Mocha.SuiteFunction; ~~~~~~~~

node_modules/@types/jest/index.d.ts:37:13 37 declare var describe: jest.Describe; ~~~~~~~~ ‘describe’ was also declared here.

node_modules/@types/mocha/index.d.ts:2636:13 - error TS2403: Subsequent variable declarations must have the same type. Variable ‘xdescribe’ must be of type ‘Describe’, but here has type ‘PendingSuiteFunction’.

2636 declare var xdescribe: Mocha.PendingSuiteFunction; ~~~~~~~~~

node_modules/@types/jest/index.d.ts:39:13 39 declare var xdescribe: jest.Describe; ~~~~~~~~~ ‘xdescribe’ was also declared here.

node_modules/@types/mocha/index.d.ts:2650:13 - error TS2403: Subsequent variable declarations must have the same type. Variable ‘it’ must be of type ‘It’, but here has type ‘TestFunction’.

2650 declare var it: Mocha.TestFunction; ~~

node_modules/@types/jest/index.d.ts:40:13 40 declare var it: jest.It; ~~ ‘it’ was also declared here.

node_modules/@types/mocha/index.d.ts:2664:13 - error TS2403: Subsequent variable declarations must have the same type. Variable ‘test’ must be of type ‘It’, but here has type ‘TestFunction’.

2664 declare var test: Mocha.TestFunction; ~~~~

node_modules/@types/jest/index.d.ts:43:13 43 declare var test: jest.It; ~~~~ ‘test’ was also declared here.

node_modules/@types/mocha/index.d.ts:2671:13 - error TS2403: Subsequent variable declarations must have the same type. Variable ‘xit’ must be of type ‘It’, but here has type ‘PendingTestFunction’.

2671 declare var xit: Mocha.PendingTestFunction; ~~~

node_modules/@types/jest/index.d.ts:42:13 42 declare var xit: jest.It; ~~~ ‘xit’ was also declared here.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20 (14 by maintainers)

Most upvoted comments

I ended up using the "skipLibCheck": true, option in my tsconfig.json to work around the issue for now.

I tried again today with latest version of wdio pkgs. I think the error comes from type collision from jest-jasmine and wdio-mocha defining some of the same types. So a monorepo project with both jest and wdio as common dev deps at the root level probably results in the errors. I tried moving the wdio deps from the monorepo root level to the individual pkg level - but I still need to have wdio cli, local runner etc at root level for the npm test scripts invoking the wdio bin to work. So couldn’t get it to work as expected 😞

I will try to extract and produce an example with both jest and wdio deps in a sample project when I can get some time next.