Skip to content

CT mount types relying on @cypress/ don't work #24330

@ZachJW34

Description

@ZachJW34

Current behavior

cypress/react18 has types defined in node_modules/cypress/react18/dist/index.d.ts that look like:

/// <reference types="cypress" />
/// <reference types="cypress" />
import React from 'react';
import type { MountOptions, UnmountArgs } from '@cypress/react'; // NOT GOOD
export declare function mount(jsx: React.ReactNode, options?: MountOptions, rerenderKey?: string): Cypress.Chainable<import("@cypress/react").MountReturn>;
export declare function unmount(options?: UnmountArgs): Cypress.Chainable<undefined>;

Notice the @cypress/react import (@ prefix). The types won't be found unless the user happens to have installed the mount package from npm which is unlikely. The lack of the types leads to any typing of the options.
Screen Shot 2022-10-20 at 5 20 51 PM

Desired behavior

The types for cypress/react18 (using mount from cypress npm module) should be equivalent to the types for @cypress/react18. This problem also exists for our other mount packages as they have a reliance on @cypress/mount-utils, so they should be cleaned up as well. In summary, the types should work regardless of where the mount is coming from.

Test code to reproduce

Create a react18 project outside of our repo with npm init vite. Choose TS and create a test.

Cypress Version

10.10.0

Node version

v16.17.1

Operating System

macOS 12.4

Debug Logs

No response

Other

No response

Metadata

Metadata

Assignees

Labels

CTIssue related to component testing

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions