DevExpress / testcafe-react-selectors

TestCafe selector extensions for React apps.
https://testcafe.io
MIT License
205 stars 43 forks source link

Cannot find module 'testcafe-react-selectors' or its corresponding type declarations. #190

Closed 2BC-Wasabi closed 2 years ago

2BC-Wasabi commented 2 years ago

i get this error even after i installed the packages globally, i'm using Electron React Boilerplate. and i'm trying to run the test after the app is installed

Cannot find module 'testcafe-react-selectors' or its corresponding type declarations.

tried to search for a fix but with no luck, here is my simple test.

  import { fixture, test, Selector } from 'testcafe';
  import { waitForReact, ReactSelector } from 'testcafe-react-selectors';

  fixture`Electron test`
    .page('index.html')
    .beforeEach(async () => {
      await waitForReact();
    });

  test('Test', async (t) => {
    const mydropdown= ReactSelector('myDropDown');
    await t.click(mydropdown);
    await t
      .expect(Selector('img').withAttribute('data-testid', 'react-image').exists)
      .ok();
  });
2BC-Wasabi commented 2 years ago

this fixed my issue, but i don't know if it is the correct way to do it, cmd in administrator mode

cd Install\Path npm init npm install testcafe npm install testcafe-browser-provider-electron npm install testcafe-react-selectors

testcafe "electron:." "test.e2e.ts" --dev

felis2803 commented 2 years ago

You can only import modules that are locally installed (except for built-in node.js modules such as fs or events). Global modules cannot be imported - this is a feature of node.js. The TestCafe module is an exception here (it is imported as built-in), but this only works when run with the testcafe command from the command line. So, the way you work around this problem (installing npm packages locally) is correct.