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

bug: incorrect TestingConfig/JestConfig type #5908

Closed
3 tasks done
punit-shah opened this issue Jul 25, 2024 · 1 comment · Fixed by #5910
Closed
3 tasks done

bug: incorrect TestingConfig/JestConfig type #5908

punit-shah opened this issue Jul 25, 2024 · 1 comment · Fixed by #5910
Assignees
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@punit-shah
Copy link

punit-shah commented Jul 25, 2024

Prerequisites

Stencil version

4.19.2

Current behavior

When setting certain properties in Stencil's testing config, such as restoreMocks: true, I get TypeScript errors.

Full list of properties in the JestConfig interface that are incompatible with Jest's Config type:

  • bail
  • globalSetup
  • globalTeardown
  • preset
  • prettierPath
  • resolver
  • restoreMocks
  • testRegex
  • transform

Expected behavior

These errors should not occur. Setting this property to a boolean is correct, why does it expect a string?

Steps to reproduce

Set the testing.restoreMocks property in stencil.config.ts

export const config: Config = {
  // ...
  testing: {
        // ...
        restoreMocks: true,
    },
};

TypeScript will throw the following error:

Types of property 'restoreMocks' are incompatible.
  Type 'boolean' is not assignable to type 'string'.

Additional information

Looks like the JestConfig interface contains incorrect types.

export interface JestConfig {

Could this be updated to use the Config type directly from Jest, instead of defining your own interface?

import type { Config as JestConfig } from 'jest';

export interface TestingConfig extends JestConfig {
  // ...
}
@ionitron-bot ionitron-bot bot added the triage label Jul 25, 2024
@punit-shah punit-shah changed the title Incorrect TestingConfig/JestConfig type bug: incorrect TestingConfig/JestConfig type Jul 25, 2024
@christian-bromann christian-bromann self-assigned this Jul 25, 2024
@christian-bromann christian-bromann added the Bug: Validated This PR or Issue is verified to be a bug within Stencil label Jul 25, 2024
@ionitron-bot ionitron-bot bot removed the triage label Jul 25, 2024
@christian-bromann
Copy link
Member

@punit-shah thanks for reporting. These types were updated in Jest but never revisited in Stencil. I raised a PR with an update.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants