Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testcafe_2.default is not a function #4

Closed
screendriver opened this issue Sep 10, 2019 · 4 comments
Closed

testcafe_2.default is not a function #4

screendriver opened this issue Sep 10, 2019 · 4 comments

Comments

@screendriver
Copy link

I'm using TestCafe together with Percy in a Gatsby project that uses TypeScript. My test looks like

import { Selector } from 'testcafe';
import percySnapshot from '@percy/testcafe';

fixture('Visual').page('http://localhost:9000');

test('with percy', async t => {
  await t
    .expect(Selector('title').innerText)
    .eql('This as a test');

  await percySnapshot(t, 'Integrate with Percy');
});

and I'm running the tests with

percy exec -- testcafe chrome:headless 'test/e2e/**/*.ts' --app 'gatsby serve'

Unfortunately I get the error

   1) TypeError: testcafe_2.default is not a function

      Browser: HeadlessChrome 76.0.3809 / Mac OS X 10.14.6

          6 |test('with percy', async t => {
          7 |  await t
          8 |    .expect(Selector('title').innerText)
          9 |    .eql('This as a test');
         10 |
       > 11 |  await percySnapshot(t, 'Integrate with Percy');
         12 |});
         13 |

         at <anonymous> (/Users/me/project/test/e2e/visual.test.ts:11:22)
         at fulfilled (/Users/me/project/test/e2e/visual.test.ts:5:58)
         at $$testcafe_test_run$$Wv1mGfF2z$$
      (/Users/me/project/node_modules/testcafe/src/api/test-run-tracker.js:76:16)
         at $$testcafe_test_run$$Wv1mGfF2z$$
      (/Users/me/project/node_modules/testcafe/src/api/test-run-tracker.js:76:16)

All other tests that are not calling percySnapshot() works perfectly.

@Robdel12
Copy link
Contributor

Hey @screendriver, this sounds like a TypeScript import issue. Would you be able to try import * as percySnapshot?

@screendriver
Copy link
Author

Oh man 🤦‍♂ How could I have overlooked that? Thank you very much 👍

@Robdel12
Copy link
Contributor

Ha, no worries! That still gets me a lot of the time when using TS 😆

@CoraDale
Copy link

I'm having this problem as well, but I can't tell what the actual solution here is?
Is the solution to import percySnapshot with import * as percySnapshot from '@percy/testcafe';? That isn't working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants