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

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

Closed
ZachJW34 opened this issue Oct 20, 2022 · 4 comments
Closed

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

ZachJW34 opened this issue Oct 20, 2022 · 4 comments
Assignees
Labels
CT Issue related to component testing

Comments

@ZachJW34
Copy link
Contributor

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

@ZachJW34 ZachJW34 added the CT Issue related to component testing label Oct 20, 2022
@baus
Copy link
Collaborator

baus commented Oct 24, 2022

@ZachJW34
Copy link
Contributor Author

For cypress/react18 I would expect the types to be copied over to the disted output, similar to how the source code is copied. If it were copied, this would ensure that both cypress/react18 and @cypress/react18 have equivalent types. Unless @cypress/react is listed as a dependency, the published package won't have proper types.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 31, 2022

The code for this is done in cypress-io/cypress#24415, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 10, 2022

Released in 11.0.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v11.0.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CT Issue related to component testing
Projects
None yet
Development

No branches or pull requests

4 participants