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

Current tests are not covering Node environment #1179

Open
Ldoppea opened this issue May 25, 2022 · 1 comment
Open

Current tests are not covering Node environment #1179

Ldoppea opened this issue May 25, 2022 · 1 comment

Comments

@Ldoppea
Copy link
Member

Ldoppea commented May 25, 2022

Current Jest configuration is using testEnvironment: 'jest-environment-jsdom-sixteen' which means that all tests are run in a valid DOM environment.

This is problematic as CozyClient can be used in a Node.js environment (i.e. connectors' jobs)

A recent consequence from this configuration is that we are not able to correctly test the securiseUri method that is based on window global object. This method should not throw in Node.js environment which doesn't declare the window global object.
Because tests are run using jest-environment-jsdom-sixteen, all tests were success in #1176
But the method was still failing in Node.js environment. So we fixed that in #1180 but without ability to add a unit test to validate the change.

A good way to resolve this would be to run tests 2 times. One time with the jest-environment-jsdom-sixteen environment, and another time with the node environment.
But here a lot of existing tests would fail as some of them are not supposed to be run in node environment.
We should find a way to discriminate node only tests and DOM only tests.

@paultranvan
Copy link
Contributor

The node examples might be enough to guarantee the node execution is not broken. It won't cover everything but at least check the init/query methods

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

No branches or pull requests

2 participants