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.

Typescript error when importing from @cypress/skip-test

See original GitHub issue

Importing like this

import { onlyOn, skipOn } from '@cypress/skip-test';

Gives me the error:

TS2306: File ‘node_modules/@cypress/skip-test/index.d.ts’ is not a module.

While running tsc --traceResolution reports the following:

======== Resolving module '@cypress/skip-test' from 'src/pages/EServices/components/GeneralInformation/GeneralInformation.spec.tsx'. ========
Explicitly specified module resolution kind: 'NodeJs'.
'baseUrl' option is set to 'src', using this value to resolve non-relative module name '@cypress/skip-test'.
Resolving module name '@cypress/skip-test' relative to base url 'src' - 'src/@cypress/skip-test'.
Loading module as file / folder, candidate module location 'src/@cypress/skip-test', target file type 'TypeScript'.
Loading module '@cypress/skip-test' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'src/pages/EServices/components/GeneralInformation/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'cypress__skip-test'
Directory 'src/pages/EServices/components/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'cypress__skip-test'
Directory 'src/pages/EServices/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'cypress__skip-test'
Directory 'src/pages/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'cypress__skip-test'
Directory 'src/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'cypress__skip-test'
Directory 'node_modules/@types' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'cypress__skip-test'
Directory 'packages/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'cypress__skip-test'
Found 'package.json' at 'node_modules/@cypress/skip-test/package.json'.
'package.json' does not have a 'typesVersions' field.
File 'node_modules/@cypress/skip-test.ts' does not exist.
File 'node_modules/@cypress/skip-test.tsx' does not exist.
File 'node_modules/@cypress/skip-test.d.ts' does not exist.
'package.json' does not have a 'typings' field.
'package.json' has 'types' field 'index.d.ts' that references 'node_modules/@cypress/skip-test/index.d.ts'.
File 'node_modules/@cypress/skip-test/index.d.ts' exist - use it as a name resolution result.
Resolving real path for 'node_modules/@cypress/skip-test/index.d.ts', result 'node_modules/@cypress/skip-test/index.d.ts'.
======== Module name '@cypress/skip-test' was successfully resolved to 'node_modules/@cypress/skip-test/index.d.ts' with Package ID '@cypress/skip-test/index.d.ts@2.5.0'. ========

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bahmutovcommented, Jun 8, 2021

🎉 This issue has been resolved in version 2.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

1reaction
bahmutovcommented, Feb 24, 2021

Sure if it fixed the problem

Sent from my iPhone

On Feb 24, 2021, at 15:04, Laura Robb notifications@github.com wrote:

I believe that adding the following to node_modules/@cypress/skip-test/index.d.ts is necessary to get TypeScript on the same page with the module exports defined in node_modules/@cypress/skip-test/index.js:

In index.d.ts:

export const skipOn: (nameOrFlag: string|boolean, cb?: () => void) => Cypress.Chainable<any>; export const onlyOn: (nameOrFlag: string|boolean, cb?: () => void) => Cypress.Chainable<any>; export const isOn: (name: string) => boolean The exports in index.js:

module.exports = { skipOn, onlyOn, isOn } Reference: TypeScript documentation for Modules d.ts

@bahmutov would you like a PR for this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Skipping a test in Cypress conditionally - Stack Overflow
My intention is to check if an error is displayed on a website, and skip the test if it does. Otherwise continue with...
Read more >
@cypress/skip-test - npm
Simple commands to skip a test based on platform, browser or an url. Latest version: 2.6.1, last published: 2 years ago.
Read more >
TypeScript - Cypress Documentation
Cypress ships with official type declarations for TypeScript. This allows you to write your tests in TypeScript. Install TypeScript To use TypeScript.
Read more >
Cypress Testing Library
Cypress Testing Library allows the use of dom-testing queries ... import '@testing-library/cypress/add-commands' ... With TypeScript​.
Read more >
Testing | Next.js
Cypress is a test runner used for End-to-End (E2E) and Integration Testing. ... pages/index.js import Link from 'next/link' export default function Home() ...
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