eduter / screeps-jest

Helper functions and environment for unit testing your Screeps code with Jest.
14 stars 4 forks source link

Fail when using Jest@26 #5

Closed brisberg closed 4 years ago

brisberg commented 4 years ago

Fails when using the latest version of Jest (26.1.0).

Jest now access a few internal calls on mocked functions which trigger the "unmocked properties" safe guard.

Unexpected access to unmocked property "Memory._isMockFunction".
    Did you forget to mock it?
    If you intended for it to be undefined, you can explicitly set it to undefined (recommended) or set "allowUndefinedAccess" argument to true.

      at Object.get (node_modules/screeps-jest/src/mocking.js:66:23)
          at Array.forEach (<anonymous>)
TypeError: globalMock.mockClear is not a function

      at Object.keys.forEach.key (node_modules/jest-runtime/build/index.js:939:24)
          at Array.forEach (<anonymous>)

Interesting issue with reproducing this with your test cases. Pulling the repo and upgrading to Jest 26 still causes all the tests to pass. However, if you SKIP the test about mockGlobal where allowUndefined is true, the other tests fail with the above errors.

I am guessing that something is not being cleaned up correctly between cases, as those tests should be independent.

eduter commented 4 years ago

Thanks for finding and fixing the problem!

brisberg commented 4 years ago

Do you mind doing another release? (or at least just a tag).

I'd feel better updating my dependency to a locked version than to master itself where it might pull in future commits without warning.

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: