From afd6a00499e2f84ea49a06efe016791838364e7f Mon Sep 17 00:00:00 2001 From: Masafumi Koba <473530+ybiquitous@users.noreply.github.com> Date: Wed, 25 Oct 2023 23:08:56 +0900 Subject: [PATCH] Test ESM rules Note that this change uses the unpublished version of `jest-preset-stylelint`: https://github.com/stylelint/jest-preset-stylelint/pull/81 --- jest.setup.mjs | 8 ++++++++ package.json | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 jest.setup.mjs diff --git a/jest.setup.mjs b/jest.setup.mjs new file mode 100644 index 0000000000..6c00a1eecf --- /dev/null +++ b/jest.setup.mjs @@ -0,0 +1,8 @@ +import jestPreset from 'jest-preset-stylelint'; + +const { getTestRule, getTestRuleConfigs } = jestPreset; + +const loadLint = () => import('./lib/index.mjs').then((m) => m.default.lint); + +global.testRule = getTestRule({ loadLint }); +global.testRuleConfigs = getTestRuleConfigs({ loadLint }); diff --git a/package.json b/package.json index 4bddd64415..650c98828e 100644 --- a/package.json +++ b/package.json @@ -127,14 +127,14 @@ }, "./lib/rules/*/index.mjs": {} }, - "moduleNameMapper": { - "^stylelint$": "/lib/index.cjs" - }, "preset": "jest-preset-stylelint", "roots": [ "lib", "system-tests" ], + "setupFiles": [ + "/jest.setup.mjs" + ], "testEnvironment": "node", "testRegex": ".*\\.test\\.m?js$|rules/.*/__tests__/.*\\.m?js$", "watchPlugins": [