vtex / vtex.js

VTEX SDK for JavaScript
MIT License
120 stars 52 forks source link

How to test with vtexjs #97

Open Marcos-Iorio opened 11 months ago

Marcos-Iorio commented 11 months ago

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

mica-acct commented 11 months ago

Have you tried this?

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

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

Marcos-Iorio commented 11 months ago

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 commented 4 months ago

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.