Skip to content

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

@tkivela

Description

@tkivela

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions