VSCode Pa11y and typescript - /node_modules/.pnpm/@cypress-audit+pa11y@1.4.2/node_modules/@cypress-audit/pa11y/index.d.ts' is not a module
Opened this issue · 1 comments
mark0203 commented
What does not work?
In Visual studio code, I get this message "File 'C:/PROJ/Cypress_Typescript_Pa11y/node_modules/.pnpm/@cypress-audit+pa11y@1.4.2/node_modules/@cypress-audit/pa11y/index.d.ts' is not a module.ts(2306)"
How to reproduce?
I've used an empty cypress Typescript framework like this one: https://github.com/mark0203/ta_docs/tree/main/CYPRESS/Cypress_Typescript_empty_framework
pnpm install --save-dev @cypress-audit/pa11y
support/commands.ts
has this:import "@cypress-audit/pa11y/commands";
- The e2e specfile looks like this
describe('template', () => {
it('simplest test', () => {
cy.visit('/')
cy.pa11y()
})
})
cypress.config.ts
looks like this and has an issue on line 2- File 'C:/PROJ/Cypress_Typescript_Pa11y/node_modules/.pnpm/@cypress-audit+pa11y@1.4.2/node_modules/@cypress-audit/pa11y/index.d.ts' is not a module.ts(2306)
const { defineConfig } = require("cypress");
const { pa11y, prepareAudit } = require("@cypress-audit/pa11y");
module.exports = defineConfig({
video: false,
e2e: {
setupNodeEvents(on, config) {
on("before:browser:launch", (browser = {}, launchOptions) => {
prepareAudit(launchOptions);
});
on("task", {
pa11y: pa11y(),
});
},
baseUrl: 'https://example.cypress.io',
},
});
- in
tsconfig.json
visual studio code gives me this error on line 1 - Cannot find type definition file for 'node'.
The file is in the program because:
Entry point of type library 'node' specified in compilerOptions ts
Expected behavior
- The test does run, so it could also be something Visual studio code related?
- I get no errors in Visual studio code when using a javascript framework
- So I'm expecting no errors when using a typescript framework
Environment (please complete the following information):
- OS: Windows10 x64
- Chrome version: 115.0.5790.173
- Cypress version: 12.17.3
- VSCode version: 1.81.1
- Node.js: 16.17.1
ChaseBig commented
I believe this fixed it for me const { pa11y } = require("@cypress-audit/pa11y");