Skip to content

❄️ Bugfix Flaky Unit Tests For JavaScript Subprojects #364

Closed

Description

@nigthknight

🐞 Bug report

Developing some new Hooks we noticed some strange behavior between independet JS Subprojects when we executed our unit tests with jest.
It seems that mocking modules in different subprojects causes some tests to fail when executed together although they are independent and there mocks should be seperate.

Until now we are not quite sure why this happens. We think it could be a problem related to es/commonJS modules

Activity

  1. changed the title [-]Flaky Unit Tests For JavaScript Subprojects[/-] [+]❄️Flaky Unit Tests For JavaScript Subprojects[/+] on Apr 10, 2021
  2. changed the title [-]❄️Flaky Unit Tests For JavaScript Subprojects[/-] [+]❄️Bugfix Flaky Unit Tests For JavaScript Subprojects[/+] on Apr 10, 2021
  3. changed the title [-]❄️Bugfix Flaky Unit Tests For JavaScript Subprojects[/-] [+]❄️ Bugfix Flaky Unit Tests For JavaScript Subprojects[/+] on Apr 16, 2021
  4. twwd commented on Apr 16, 2021

    @twwd
    Contributor

    I would guess that the tests are not executed independently. Jest also gives an appropriate warning about the duplicate mocks.

    jest-haste-map: duplicate manual mock found: axios
      The following files share their name; please delete one of them:
        * <rootDir>/generic-webhook/__mocks__/axios.js
        * <rootDir>/teams-webhook/__mocks__/axios.js
    
    jest-haste-map: duplicate manual mock found: axios
      The following files share their name; please delete one of them:
        * <rootDir>/hooks/generic-webhook/__mocks__/axios.js
        * <rootDir>/hooks/teams-webhook/__mocks__/axios.js
    
  5. self-assigned this
    on Apr 16, 2021
  6. twwd commented on Apr 16, 2021

    @twwd
    Contributor
  7. nigthknight commented on Apr 16, 2021

    @nigthknight
    MemberAuthor

    That is correct but on this branch https://github.com/fuhrmeistery/secureCodeBox/tree/feature/notification-hook
    We removed both custom mock implementations completely and use jest.mock() instead and the issue still persisted

    I would guess that the tests are not executed independently. Jest also gives an appropriate warning about the duplicate mocks.

    jest-haste-map: duplicate manual mock found: axios
      The following files share their name; please delete one of them:
        * <rootDir>/generic-webhook/__mocks__/axios.js
        * <rootDir>/teams-webhook/__mocks__/axios.js
    
    jest-haste-map: duplicate manual mock found: axios
      The following files share their name; please delete one of them:
        * <rootDir>/hooks/generic-webhook/__mocks__/axios.js
        * <rootDir>/hooks/teams-webhook/__mocks__/axios.js
    
  8. removed their assignment
    on Apr 20, 2021
  9. Weltraumschaf commented on Jul 20, 2023

    @Weltraumschaf
    Member

    Seems not to be a problem anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions