DevExpress/testcafe-react-selectors

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

2BC-Wasabi opened this issue · 2 comments

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();
  });

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

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.