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

Missing mock files leads to failed tests #177

Closed
wwang107 opened this issue May 22, 2021 · 0 comments · Fixed by #181
Closed

Missing mock files leads to failed tests #177

wwang107 opened this issue May 22, 2021 · 0 comments · Fixed by #181

Comments

@wwang107
Copy link
Contributor

wwang107 commented May 22, 2021

Test is failing every time because static resources, such as .png, can not be imported properly in Jest. For example, in the build pipeline, one can see the error message

Test suite failed to run

    Configuration error:
    
    Could not locate module ../../assets/images/hyf-logo.png mapped as:
    /Users/wwang/Guide-IT/__mocks__/fileMock.js.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$/": "/Users/wwang/Guide-IT/__mocks__/fileMock.js"
      },
      "resolver": null
    }

To address the issue, mockFile.js need to be created.

jestjs/jest#2663

https://stackoverflow.com/questions/46898638/importing-images-breaks-jest-test

Acceptance criteria
Mock the static files properly, so the mentioned error message is gone.

@wwang107 wwang107 changed the title Missing mock static resource files leads to failed tests Missing mock files leads to failed tests May 22, 2021
wwang107 pushed a commit that referenced this issue May 23, 2021
wwang107 added a commit that referenced this issue May 23, 2021
#177: add mock file to resolve static resources in tests
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

Successfully merging a pull request may close this issue.

1 participant