testing-library / testcafe-testing-library

:ox: Simple and complete custom Selectors for Testcafe that encourage good testing practices.
http://npm.im/@testing-library/testcafe
MIT License
71 stars 15 forks source link

Unable to use any of the selectors from @testing-library/testcafe in testcafe tests #357

Closed andrew-t-james closed 2 years ago

andrew-t-james commented 2 years ago

Describe the bug Unable to use @testing-library/testcafe selectors in tests.

To Reproduce Steps to reproduce the behavior:

  1. generate a new repo with testcafe
  2. add the following test
    
    import { screen } from "@testing-library/testcafe";

fixtureGetting Started.pagehttps://devexpress.github.io/testcafe/example;

test("first test", async (t) => { // also attempted to // const group = screen.getByRole('group', { name: /your name:/i}); // within(group).getByRole('textbox');

await t .typeText(screen.getByRole("textbox", { name: /name/i }), "John Smith") .click(screen.getByRole("button", { name: /submit/i }));

await t .expect( screen.getByRole("heading", { name: /thank you, john smith!/i, }).exists ) .ok(); });

3. Add testcaferc.json to root
```json
{
  "clientScripts": [
    {
      "module": "@testing-library/dom/dist/@testing-library/dom.umd.js"
    }
  ],
  "browsers": [
    "chrome:headless"
  ],
  "src": "tests/*.test.ts"
}
  1. add this script to package.json "testcafe": "testcafe chrome:headless"

  2. Run test yarn testcafe | npm run testcafe

  3. See error

    
    Getting Started
    ✖ first test
    
    1) An error occurred in Selector code:
    
      Error: Cannot call method 'getByRole' of undefined


**Expected behavior**
Expected to be able to use getBy findBy queryBy (none of these options worked)

**Desktop (please complete the following information):**
 - OS: [macOS 12.4] (Apple M1 Chip)
 - Browser [chrome]
 - Version [e.g. 103.0.5060.53]

**Additional context**
Add any other context about the problem here.
andrew-t-james commented 2 years ago

Closing looks like it was a config issue. My bad.