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

Cypress ignores user-supplied tsconfig.json file when running tests #180

Closed
scottohara opened this issue May 25, 2020 · 0 comments
Closed

Comments

@scottohara
Copy link
Owner

In 0b1b54c we removed @cypress/webpack-preprocessor in favour of native Typescript support introduced in Cypress v4.4.0.

Previously, the webpack config used by the preprocessor included:

resolve: {
	...
	modules: [
		path.resolve(__dirname, "support"),
		...
	]
}

...to allow test files in /cypress/integration/* to resolve import specifiers relative to the /cypress/support/* directory, e.g.

// cypress/support/utils.ts
export function foo() { ... };

// cypress/integration/test.ts
import { foo } from "utils";  // <- webpack resolves this to cypress/support/utils.ts

The hope was that the existing config in cypress/tsconfig.json (already there for VS Code to resolve these paths) would achieve the same result:

{
  "compilerOptions": {
    "paths": {
		"*": [
			"cypress/support/*"
		]
	},

Unfortunately it turns out that Cypress currently ignores the user-supplied tsconfig.json file, so any compiler options specified aren't actually used when building & running the tests.

Hopefully this will change with a future release of Cypress.

For now, the workaround was to change all imports to be relative to the current file, e.g.

// cypress/integration/test.ts
import { foo } from "../support/utils";

cypress-io/cypress#7188

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

No branches or pull requests

1 participant