mattphillips / jest-chain

Chain Jest matchers together to create one powerful assertion 🃏⛓

Home Page:https://www.npmjs.com/package/jest-chain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot read property 'not' of undefined

rbutera opened this issue · comments

  • package version: ^1.0.3
  • node version: v10.1.0
  • npm (or yarn) version: yarn 1.10.1

Trying to use jest-chain in my project. I have a testSetup file that looks like this

// require any test frameworks
require("jest-extended")
require("jest-chain")

and a package.json that contains:

  "devDependencies": {
     // .... irrelevant packages removed
    "jest": "^23.6.0",
    "jest-chain": "^1.0.3",
    "jest-extended": "^0.10.0",
    "jest-immutable-matchers": "^2.0.1",
    "jest-webextension-mock": "^3.4.0",
  },
  "jest": {
    "setupTestFrameworkScriptFile": "./testSetup.js"
  }

The test file looks like this:

it("should only append actions specified in actions.names to the history key", () => {
    const initialState = {
      history: []
    }
    const finalState = {
      history: [
        actions.KEY_PRESS("q", false),
        actions.KEY_PRESS("w", false),
        actions.KEY_PRESS("e", false),
        actions.KEY_PRESS("r", false),
        actions.KEY_PRESS("t", false),
        actions.KEY_PRESS("y", false)
      ],
      suggestions: []
    }

    let result = clone(initialState.history)

    finalState.history.forEach(action => {
      result = clone(history(result, action))
    })

    const unsupported = { type: "foo" }

    result = clone(history(result, unsupported))

    expect(result)
      .toEqual(finalState.history)
      .not.toContain(unsupported)
  })

when I use chained matchers I get errors like TypeError: Cannot read property 'toContain' of undefined or TypeError: Cannot read property 'not' of undefined

will check if jest-extended works, it may be a tooling issue.

Any ideas on how to fix?

Hey @Raigasm I'm not sure what is going wrong exactly, I've just made a repo of using both jest-extended and jest-chain which seems to be working fine for me. You can check it out here: https://github.com/mattphillips/jest-chain-with-jest-extended

Would you be able to create a small reproduction repo without any proprietary code, that I could clone and run to see the error in action?