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

How to test with vtexjs #97

Open
Marcos-Iorio opened this issue Oct 4, 2023 · 3 comments
Open

How to test with vtexjs #97

Marcos-Iorio opened this issue Oct 4, 2023 · 3 comments

Comments

@Marcos-Iorio
Copy link

Expected Behavior

I have installed text-tools/react from vtex that implements jest and @testing-library/react under the hood
but when i try to test it throws me a vtexjs is undefined error, since is a native module of js I cannot import it in the test file

image

Current Behavior

Possible Solution

Steps to Reproduce (for bugs)

  1. instal vtex-test-tools
  2. run yarn test

Context

I'm trying to test components of the checkout with the app installed checkout-ui-custom

Your Environment

  • Version used:
  • Environment name and version (e.g. Chrome 39, node.js 5.4):
  • Operating System and version (desktop or mobile):
  • Link to your project:
@mica-acct
Copy link

Have you tried this?

`import { useOrderForm } from 'vtex.order-manager/OrderForm'

const {
orderForm: { id: orderFormId },
} = useOrderForm()`

@Marcos-Iorio
Copy link
Author

Marcos-Iorio commented Oct 4, 2023

Have you tried this?

`import { useOrderForm } from 'vtex.order-manager/OrderForm'

const { orderForm: { id: orderFormId }, } = useOrderForm()`

Hi! I'm not using vtex.order-maganer because in the docs says is not already full tested, but this is a package that i have to install? i will try

Edit: I try installing this dep but it throws me that it doesn't exists :(

@marcosabreudev
Copy link

This happens because the jest (vtex test tools) does not have access to the vtexjs module implementation. So you need to make a mock for vtexjs.

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

3 participants