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

❄️ Bugfix Flaky Unit Tests For JavaScript Subprojects #364

Closed
fuhrmeistery opened this issue Apr 9, 2021 · 4 comments
Closed

❄️ Bugfix Flaky Unit Tests For JavaScript Subprojects #364

fuhrmeistery opened this issue Apr 9, 2021 · 4 comments
Labels
bug Bugs

Comments

@fuhrmeistery
Copy link
Member

🐞 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

@fuhrmeistery fuhrmeistery added the bug Bugs label Apr 9, 2021
@rseedorff rseedorff changed the title Flaky Unit Tests For JavaScript Subprojects ❄️Flaky Unit Tests For JavaScript Subprojects Apr 10, 2021
@rseedorff rseedorff changed the title ❄️Flaky Unit Tests For JavaScript Subprojects ❄️Bugfix Flaky Unit Tests For JavaScript Subprojects Apr 10, 2021
@rseedorff rseedorff changed the title ❄️Bugfix Flaky Unit Tests For JavaScript Subprojects ❄️ Bugfix Flaky Unit Tests For JavaScript Subprojects Apr 16, 2021
@twwd
Copy link
Contributor

twwd commented Apr 16, 2021

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

@twwd twwd self-assigned this Apr 16, 2021
@twwd
Copy link
Contributor

twwd commented Apr 16, 2021

Also see jestjs/jest#2070

@fuhrmeistery
Copy link
Member Author

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

@twwd twwd removed their assignment Apr 20, 2021
secureCodeBoxBot added a commit that referenced this issue Nov 18, 2021
Signed-off-by: secureCodeBoxBot <securecodebox@iteratec.com>
## Release changes :
## Summary
 
 CODE_OF_CONDUCT.md CONTRIBUTING.md CONTRIBUTORS.md DCO LICENSE LICENSES Makefile README.md SECURITY.md UPGRADING.md Vagrantfile auto-discovery bin common.mk demo-targets docs hook-sdk hooks hooks.mk lurker operator package-lock.json package-lock.json.license package.json package.json.license parser-sdk scanners scanners.mk sdk.mk tests Adds support for `Job` resources - thank you @superbrothers for this contribution!
 CODE_OF_CONDUCT.md CONTRIBUTING.md CONTRIBUTORS.md DCO LICENSE LICENSES Makefile README.md SECURITY.md UPGRADING.md Vagrantfile auto-discovery bin common.mk demo-targets docs hook-sdk hooks hooks.mk lurker operator package-lock.json package-lock.json.license package.json package.json.license parser-sdk scanners scanners.mk sdk.mk tests Adds option to disable colour output when using `pretty` formatting (package only)
 CODE_OF_CONDUCT.md CONTRIBUTING.md CONTRIBUTORS.md DCO LICENSE LICENSES Makefile README.md SECURITY.md UPGRADING.md Vagrantfile auto-discovery bin common.mk demo-targets docs hook-sdk hooks hooks.mk lurker operator package-lock.json package-lock.json.license package.json package.json.license parser-sdk scanners scanners.mk sdk.mk tests Enabled Dependabot and updates dependencies
 
 ## Changelog
 
 b68cabd Update version to 0.15.0 (#372)
 7f54326 Bump github.com/jetstack/cert-manager from 1.6.0 to 1.6.1 (#371)
 9cdecb3 Bump k8s.io/apiextensions-apiserver from 0.22.2 to 0.22.3 (#368)
 6cc7a75 Add support for kind Job (#370)
 0ef3005 Bump github.com/jetstack/cert-manager from 1.5.4 to 1.6.0 (#365)
 e5c797a Bump k8s.io/apimachinery from 0.22.2 to 0.22.3 (#369)
 d597928 Bump k8s.io/apiextensions-apiserver from 0.21.3 to 0.22.2 (#362)
 79cce8c Remove wip probot (#364)
 700c39f Bump github.com/jetstack/cert-manager from 1.4.1 to 1.5.4 (#363)
 fe44171 Fix dependabot (#358)
 374a428 Support parsing for server specs (#356)
 50c618b Add Support for Services (#353)
 7b57f85 Update dependencies and add dependabot (#354)
 2d8282c Make k8s and override packages public (#351)
 47c31d5 Add option to disable printing results in color (#350)
 ca64457 Remove deprecated mountds auditor (#349)
 863e367 Remove example dependency on internal packages (#348)
 
 
 ## Docker images
 
 - `docker pull shopify/kubeaudit:latest`
 - `docker pull shopify/kubeaudit:0.15.0`
 - `docker pull shopify/kubeaudit:v0.15`
@Weltraumschaf
Copy link
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
Labels
bug Bugs
Projects
None yet
Development

No branches or pull requests

3 participants