question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: exports is not defined when calling injectAxe() through typescript

See original GitHub issue

I have this in my support/index.ts

my tsconfig.json looks like this:

{
  "compilerOptions": {
    "lib": [
      "dom",
      "es2015",
      "es5",
      "es6",
      "es2015"
    ],
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": false,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
  },
  "files": [
    "./support/index.d.ts"
  ]
}

I have this test:

describe("TypeScript", () => {
  it("checks shape of an object", () => {
    cy.visit('http://localhost:6001')
    cy.injectAxe();
  });
})

It fails with

ReferenceError: exports is not defined at axeFunction (eval at cy.window.then.window (http://localhost:6001/__cypress/tests?p=cypress/support/index.ts-538:111:12), <anonymous>:16:14) at eval (eval at cy.window.then.window (http://localhost:6001/__cypress/tests?p=cypress/support/index.ts-538:111:12), <anonymous>:15287:3) at eval (<anonymous>)

Why would this be?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

5reactions
avanslaarscommented, Apr 3, 2020

@rlaucik @Annie-Huang The latest release of cypress-axe (0.8.1) should take care of this issue.

4reactions
Annie-Huangcommented, Mar 13, 2020

What is the fix for this problem? I got the same one…

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError: exports is not defined in TypeScript | bobbyhadz
To solve the Uncaught ReferenceError: exports is not defined, add a script tag that defines an `exports` variable, e.g. `` above your JS...
Read more >
Typescript ReferenceError: exports is not defined
On a node.js server? You will need a module loader in the run-time environment that the javascript finally runs in. From the compiler...
Read more >
How to fix ReferenceError: exports is not defined TypeScript
If you are getting the error for code that runs in the browser, try defining a global exports variable above the script tags...
Read more >
Javascript – How to fix “ReferenceError: exports is not defined ...
If I write a .ts with any kind of import or export instruction the resulting .js will generate the following error when loaded...
Read more >
react 灰符发布 - CSDN
We set calm to null , because it's the default value which you get by not including it at ... export default function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found