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

TS2345 error: testIsolation not in cypress.d.ts -> TestConfigOverrides #23911

Closed
rafal-pomocnik-captivateiq opened this issue Sep 21, 2022 · 7 comments · Fixed by #24603
Closed
Assignees

Comments

@rafal-pomocnik-captivateiq
Copy link

rafal-pomocnik-captivateiq commented Sep 21, 2022

Current behavior

When trying to use testIsolation option in test suite at describe level like mentioned in https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Test-Isolation, typescript check marks it with below error:

TS2345: Argument of type '{ testIsolation: string; }' is not assignable to parameter of type 'TestConfigOverrides'.   Object literal may only specify known properties, and 'testIsolation' does not exist in type 'TestConfigOverrides'.

Even though - it is working fine when testIsolation:'strict' is added there and it utilizes this function properly.

Desired behavior

tsc using cypress.d.ts not complaining about it.

Test code to reproduce

// tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "lib": ["es5", "dom"],
    "types": ["cypress", "node"]
  },
  "include": ["**/*.cy.ts"]
}

// test.cy.ts
describe('test name', { testIsolation: 'strict' }, () => {})

Cypress Version

10.8.0

Node version

v16.14.0

Operating System

macOS 12.6

Debug Logs

No response

Other

No response

@ZachJW34
Copy link
Contributor

Thanks for opening the issue @rafal-pomocnik-captivateiq, I can verify that our types aren't properly reflecting this option. A change will need to be made here to the TestConfigOverrides. Since it is a suite level override, maybe we change up the types such that it does not show up in the test level overrides (it('should', { ...options }, () => { ... })).

If you're interested in contributing, we would appreciate a PR!

@ZachJW34 ZachJW34 self-assigned this Sep 21, 2022
@rafal-pomocnik-captivateiq
Copy link
Author

rafal-pomocnik-captivateiq commented Sep 21, 2022

@ZachJW34 both describe/context suite level and it test level though uses currently TestConfigOverrides, to have different interface for both it seems there would be a need for creating TestSuiteConfigOverride (extending TestConfigOverrides?) with the additional testIsolation option (at least) and updating SuiteFunction/ExclusiveSuiteFunction/PendingSuiteFunction interfaces with new TestSuiteConfigOverride - is that correct?

Or just extend TestConfigOverrides with additional testIsolation option that will actually work on suite level only, on test level though tsc check will accept it, but I guess it will just throw: CypressError: The `testIsolation` configuration can only be overridden from a suite-level override.

@ZachJW34
Copy link
Contributor

The latter is the easiest, looks like we don't have a pattern for suite level vs test level but like you said we do throw an error if provided. A simple Omit<TestConfigOverrides, 'testIsolation'> would work current pattern is ok for now, but ideally the types should reflect what options are valid

@rafal-pomocnik-captivateiq
Copy link
Author

Cool, thanks @ZachJW34! I have some code prepared, but it seems I lack perms to push branch to remote - can you advise? 🙏

@ZachJW34
Copy link
Contributor

@rafal-pomocnik-captivateiq We have a contributing guide that I would recommend going through. Then, you can fork the repo and contribute a PR from the forked repo.

Glad you're looking to fix it, we appreciate it!

@nagash77 nagash77 added CT Issue related to component testing routed-to-ct labels Sep 29, 2022
@nagash77 nagash77 added routed-to-e2e and removed stage: icebox CT Issue related to component testing labels Sep 29, 2022
@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Nov 8, 2022
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Nov 10, 2022
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Nov 10, 2022

The code for this is done in cypress-io/cypress#24603, 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 15, 2022

Released in 11.1.0.

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

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

Successfully merging a pull request may close this issue.

4 participants