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

mobx 5.0.0-beta.6 gives "TypeError: allKeys[x].match is not a function" when testing TS Array with Jest #1567

Closed
tkivela opened this issue May 30, 2018 · 2 comments

Comments

@tkivela
Copy link

tkivela commented May 30, 2018

I have a small template project with Mobx 4.2 / Typescript which works fine, including testing store with Jest.

I updated Mobx dependency to 5.0.0-beta.6 and the code seems to work otherwise fine but testing the store gives an error "TypeError: allKeys[x].match is not a function". The row which fails just tests TypeScript Array equality to [].

Output when running 'yarn' and then 'yarn test':
FAIL src/stores/app/index.test.ts
● AppStore › addCounterNote should add new note to notes array beginning

TypeError: allKeys[x].match is not a function

   6 | 
   7 |     expect(store.counter).toEqual(0)
>  8 |     expect(store.notes).toEqual([])
   9 |     store.addCounterNote()
  10 |     expect(store.counter).toEqual(1)
  11 |     expect(store.notes.length).toEqual(1)
  
  at Object.<anonymous> (src/stores/app/index.test.ts:8:25)

A repository which reproduces the problem can be found at https://github.com/tkivela/react-ts-mobx-template-v5jestproblem

I'm not sure if this is a Mobx problem but the fact that same works with Mobx 4.2 implies that the problem could atleast be a compatibility issue which should be documented somewhere in v5 docs.

@mweststrate mweststrate mentioned this issue Jun 1, 2018
16 tasks
@mweststrate
Copy link
Member

mweststrate commented Jun 4, 2018

This is a bug in Jest, see: jestjs/jest#6391

mweststrate added a commit that referenced this issue Jun 4, 2018
@tkivela
Copy link
Author

tkivela commented Jun 4, 2018

Ok, thanks @mweststrate , nice find! I hope they merge your PR to Jest soon. I'll close this for now as the problem was not actually in Mobx.

@tkivela tkivela closed this as completed Jun 4, 2018
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

No branches or pull requests

2 participants