Skip to content

[bug]: Cannot use vitest as UT library #1431

Open
@mazzucchelli

Description

@mazzucchelli

What version of strapi-design-system are you using?

1.12.2

What's Wrong?

vitest consumes mjs bundles which throw these type of errors

Screenshot 2023-10-18 alle 10 06 49

more info: https://github.com/vitest-dev/vitest/discussions/4233types

To Reproduce

Unit test a component containing a SimpleMenu or a Combobox

Expected Behaviour

The design system should be testable using vitest library.

At the moment this issue can be bypassed by updating the export section of the package to use only js files, and not mjs. But it seems an ugly workaround that could damage other consumers of the design system

from

"exports": {
    "./package.json": "./package.json",
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.mjs",
      "require": "./dist/index.js",
      "default": "./dist/index.js"
    },
    "./v2": {
      "types": "./dist/v2/index.d.ts",
      "import": "./dist/v2/index.mjs",
      "require": "./dist/v2/index.js",
      "default": "./dist/v2/index.js"
    },
    "./*": "./dist/*"
  },

to

"exports": {
    "./package.json": "./package.json",
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.js",
      "require": "./dist/index.js",
      "default": "./dist/index.js"
    },
    "./v2": {
      "types": "./dist/v2/index.d.ts",
      "import": "./dist/v2/index.js",
      "require": "./dist/v2/index.js",
      "default": "./dist/v2/index.js"
    },
    "./*": "./dist/*"
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: primitivesrelates to primitives packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions