Skip to content

Conversation

@theinterned
Copy link
Contributor

@theinterned theinterned commented Mar 23, 2020

Module is preferable to absolute file path as it doesn't assume the location of node_modules folder and works better with monorepos using yarn workspaces etc. where dependencies may be hoiseted.

This { "module": "npm module" } syntax is documented here https://devexpress.github.io/testcafe/documentation/using-testcafe/configuration-file.html#clientscripts — see the example of how "loadsh" is loaded.

module is preferable to abs file path as it works with workspaces etc.
@alexkrolick alexkrolick requested a review from benmonro March 27, 2020 20:31
```json
"clientScripts": [
"./node_modules/@testing-library/dom/dist/@testing-library/dom.umd.js"
"module":"@testing-library/dom/dist/@testing-library/dom.umd.js"
Copy link
Member

@benmonro benmonro Mar 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexkrolick @theinterned is there docs on this syntax somewhere? I'm not familiar w/ it. also if this works, that doesn't look like valid json to me... is something off?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right you are ... I edited this in the GitHub interface ... let me update

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benmonro thanks for reviewing this. I updated the description with a link to the TestCafe docs for this syntax. https://devexpress.github.io/testcafe/documentation/using-testcafe/configuration-file.html#clientscripts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh very cool, I didn't realize they added that! Actually let me hold off on merging this, I want to see if we can simplify it even further and just do

{module:"@testing-library/dom"}

Copy link
Contributor Author

@theinterned theinterned Mar 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried running my repo with {module:"@testing-library/dom"} and it didn't work.

1) - Error in fixture.beforeEach hook - An error occurred in the '@testing-library/dom' module injected into the tested page. Make sure that this module can be executed in the browser environment. Error details: ReferenceError: require is not defined Browser: Chrome 80.0.3987.149 / macOS 10.15.4 
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dang. ok in that case i'll approve. :)

Copy link
Contributor Author

@theinterned theinterned Mar 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue seems to be that the "main" entry in @testing-library/dom points to "dist/index.js", as opposed to the umd build — there is a "umd:main" entry in the package.json too, but I would guess TestCafe doesn't see that.

https://github.com/testing-library/dom-testing-library/blob/master/package.json#L5-L7

I hacked the main in my node modules folder:

- "main": "dist/index.js", + "main": "dist/@testing-library/dom.umd.js",

And the tests run with

{ "clientScripts": [ { "module": "@testing-library/dom" } ] }
Copy link
Member

@benmonro benmonro Mar 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah @theinterned i filed an issue about this w/ testcafe way back: DevExpress/testcafe#4176

looks like it's still open

@benmonro benmonro merged commit 2fdf844 into testing-library:master Mar 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants