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

Fix/test cases #691

Merged
merged 3 commits into from
Feb 14, 2024
Merged

Fix/test cases #691

merged 3 commits into from
Feb 14, 2024

Conversation

sehmbimanvir
Copy link
Contributor

This PR is to fix test cases. Currently if you're running

yarn test

it's throwing various errors

 ReferenceError: DEPRECATED_ADAPTER_COMPONENT is not defined
 ReferenceError: ENABLE_INNER_HTML is not defined

To fix this, globals has been added. Here is the reference link: https://docs.taro.zone/docs/external-libraries/#jest.

Next fix is to map @tarojs/components correctly. Currently in jest.config.js it was mapped to @tarojs/components/dist-h5/react. Due to which running yarn test was throwing below error.

Please check your configuration for these entries:
{
  "moduleNameMapper": {
    "/@tarojs\/components/": "@tarojs/components/dist-h5/react"
  },
  "resolver": undefined
}

But this path doesn't exists. Now it should be mapped to @tarojs/components/lib/react, like

// jest.config.js
{
  moduleNameMapper: {
    '@tarojs/components': '@tarojs/components/lib/react',
  }
}

Last fix is for packages/core/src/navbar/__tests__/navbar.test.tsx where invalid constant was exported from styles. Now it's corrected to import { HAIRLINE_BORDER_BOTTOM } from "../../styles/hairline"

Fixing 
```bash
 ReferenceError: ENABLE_INNER_HTML is not defined
```

More details can be found here
https://docs.taro.zone/docs/external-libraries/#jest
Navbar test case fixed
@Pilotager Pilotager merged commit 50c8cd2 into mallfoundry:main Feb 14, 2024
@sehmbimanvir sehmbimanvir deleted the fix/test-cases branch February 14, 2024 16:37
@Pilotager
Copy link
Collaborator

这个我会提示 window 的错误,你那边是正常的么。

@sehmbimanvir
Copy link
Contributor Author

Can you please share error details?

@Pilotager
Copy link
Collaborator

Can you please share error details?

Hi~

WX20240219-171908@2x

When I comment out window: true in jest.config.js, I won't prompt this error.

@sehmbimanvir
Copy link
Contributor Author

sehmbimanvir commented Feb 19, 2024

For me it's working fine.

Node Version: v20.9.0

@Pilotager
Copy link
Collaborator

For me it's working fine.

Node Version: v20.9.0

thx~, what is your jest version?

@sehmbimanvir
Copy link
Contributor Author

Jest, I'm using the same. which is mentioned in package.json file.

^26.6.0

@Pilotager
Copy link
Collaborator

Jest, I'm using the same. which is mentioned in package.json file.

^26.6.0

Node Version: v20.9.0

Thank you! 🎉

@sehmbimanvir
Copy link
Contributor Author

Are you getting any warning as well while running the test cases. Regarding React Render something?

@Pilotager
Copy link
Collaborator

Pilotager commented Feb 19, 2024

Are you getting any warning as well while running the test cases. Regarding React Render something?

I only get messages that caniuse-lite is outdated and isModuleDeclaration is deprecated.

image

@sehmbimanvir
Copy link
Contributor Author

sehmbimanvir commented Feb 19, 2024

Yeah okay.

I'm working on test coverage to increase it more. Along with that I'll fix this warning message also.

@sehmbimanvir
Copy link
Contributor Author

Are you getting any warning as well while running the test cases. Regarding React Render something?

I only get messages that caniuse-lite is outdated and isModuleDeclaration is deprecated.

image

@Pilotager , I observed one thing.

yarn clean
yarn develop
yarn test

I did this and that warning stopped appearing while running tests, but if I'm following the same steps but instead of yarn develop I'm running yarn build. I am getting the same warning.

@sehmbimanvir
Copy link
Contributor Author

lodash/babel-plugin-lodash#260

Check this article once

@Pilotager
Copy link
Collaborator

lodash/babel-plugin-lodash#260

Check this article once

the warning is harmless, but nonetheless annoying.

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 this pull request may close these issues.

None yet

2 participants