design-system icon indicating copy to clipboard operation
design-system copied to clipboard

[bug]: Cannot use vitest as UT library

Open mazzucchelli opened this issue 8 months ago • 0 comments

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/*"
  },

mazzucchelli avatar Oct 23 '23 08:10 mazzucchelli