Skip to content

Testing store with jest snapshotting (mobx 5) #1613

@PDarkTemplar

Description

@PDarkTemplar

Right now if i want to test my store with snapshot there is a lot of internal information like this:

...
    +     Symbol(mobx did run lazy initializers): true,
    +     Symbol(mobx administration): ObservableObjectAdministration$$1 {
    +       "defaultEnhancer": [Function],
    +       "keysAtom": Atom$$1 {
    +         "diffValue": 0,
    +         "isBeingObserved": false,
    +         "isPendingUnobservation": false,
    +         "lastAccessedBy": 0,
    +         "lowestObserverState": 2,
    +         "name": "TreePage@149.keys",
    +         "observers": Set {},
    +       },
    +       "name": "TreePage@149",
    +       "target": [Circular],
    +       "values": Map {
    +         "selectedFolder" => SelectedFolder {
    +           "id": 1,
    +           "name": "test1",
    +           "parentFolderId": undefined,
    +           "parentOrgUnitId": undefined,
    +           "type": undefined,
    +         },
    +         "breadCrumbs" => Array [],
    +         "items" => undefined,
    +         "loading" => true,
    +         "showSearchList" => false,
    +         "openFolderType" => "folder",
...

Which i don't need. So i created small transformation for jest which automaticly transform observables to JS. But then i lost all information about class names, and now they are all objects.

 "treePage": Object {
    "breadCrumbs": Array [],
    "canCreateFolder": false,
    "inputSearch": Object {
      "items": null,
      "loading": false,
      "requestsId": Array [],
      "showItems": null,
      "term": "",
    },

So my question is, is there is some tools to deal with this?
If someone interested in my transformation i could create repo for it.

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