-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
React : Component unit test cases are excluded from Jest configuration #7787
Comments
@vishal423 could you please PR, this. I guess this was missed during the migration to Jest |
I am concerned with require.context usage as it ties code with webpack. On angular side, we used MergeJsonWebpackPlugin to handle merge outside in webpack build. Any good reason to not do same in react? |
I think yes, we should do it with |
@vishal423 will you be doing a PR? |
@deepu105, I will try and may take a day or two based on bandwidth. |
@vishal423 @deepu105 Yup I found that on the enzyme docs:
|
About |
I have changed require.context code to align with angular codebase. Basic code almost ready and should be able to raise merge in sometime. |
@wmarques, I am not sure on how it will work without enzyme configurations. On same page, they also stated below:
And per my understanding, they mean by below configurations:
|
Overview of the issue
Component unit test cases are excluded from Jest configuration. This can be checked by looking under
jest.conf.js
file.Motivation for or Use Case
Generated or newly added component unit test cases are not executed
Reproduce the error
Related issues
Suggest a Fix
jest.conf.js
-->Current:
testMatch: ['<rootDir>/src/test/javascript/spec/**/+(*.)+(spec.ts)'],
Required:
testMatch: ['<rootDir>/src/test/javascript/spec/**/+(*.)+(spec.ts?(x))'],
We also need to add enzyme configurations for enzyme functions (shallow, mount etc) to work:
jest.conf.js
-->setupFiles: ['<rootDir>/src/test/javascript/enzyme-setup.ts']
enzyme-setup.ts
-->Above configurations enable execution of component test cases, however, few test cases fail due to usage of
require.context
intranslation.ts
as:en: mergeTranslations(require.context('../../i18n/en', false, /.json$/))
As require.context is specific to webpack and Jest discourage it's use, we should identify an appropriate way to resolve this issue to enable execution of component unit test cases.
JHipster Version(s)
JHipster configuration
Using JHipster version installed globally
Executing jhipster:info
Options:
JHipster Version(s)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Environment and Tools
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
git version 2.17.1
node: v8.9.1
npm: 5.5.1
yarn: 1.7.0
Docker version 18.03.1-ce, build 9ee9f40
Congratulations, JHipster execution is complete!
Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryBrowsers and Operating System
The text was updated successfully, but these errors were encountered: