fix jest fails loading css file bug

This commit is contained in:
Bowen Tan 2022-01-29 14:34:30 +08:00
parent d88c9e9b23
commit 7c2e9983a7
7 changed files with 24 additions and 4 deletions

View File

@ -14,5 +14,8 @@ module.exports = {
},
],
},
moduleNameMapper: {
'\\.css$': 'jest-css-modules',
},
testEnvironment: 'jsdom',
};

View File

@ -65,6 +65,7 @@
"babel-jest": "^27.2.1",
"eslint-plugin-react-hooks": "^4.3.0",
"jest": "^27.2.1",
"jest-css-modules": "^2.1.0",
"postcss": "^8.4.5",
"postcss-import": "^14.0.2",
"tsup": "^5.11.0",

View File

@ -1,2 +1 @@
import './styles.css';
export { initSunmaoUIEditor } from './init';

View File

@ -13,6 +13,7 @@ import { EditorStore } from './services/EditorStore';
import { StorageHandler } from './types';
import { AppStorage } from './services/AppStorage';
import { Application, Module } from '@sunmao-ui/core';
import './styles.css';
type SunmaoUIEditorProps = {
libs?: SunmaoLib[];

View File

@ -5,8 +5,6 @@ import { sunmaoChakraUILib } from '@sunmao-ui/chakra-ui-lib';
import { initSunmaoUIEditor } from './init';
import { LocalStorageManager } from './LocalStorageManager';
import './styles.css';
type Options = Partial<{
components: Parameters<Registry['registerComponent']>[0][];
traits: Parameters<Registry['registerTrait']>[0][];

View File

@ -3,7 +3,6 @@ import { Application } from '@sunmao-ui/core';
import { Registry } from '@sunmao-ui/runtime/lib/services/registry';
import React, { StrictMode, useState } from 'react';
import ReactDOM from 'react-dom';
import './styles.css';
import { initSunmaoUIEditor } from './init';
import { sunmaoChakraUILib } from '@sunmao-ui/chakra-ui-lib';

View File

@ -5753,6 +5753,11 @@ hard-rejection@^2.1.0:
resolved "https://registry.yarnpkg.com/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883"
integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==
harmony-reflect@^1.4.6:
version "1.6.2"
resolved "https://registry.yarnpkg.com/harmony-reflect/-/harmony-reflect-1.6.2.tgz#31ecbd32e648a34d030d86adb67d4d47547fe710"
integrity sha512-HIp/n38R9kQjDEziXyDTuW3vvoxxyxjxFzXLrBr18uB47GnSt+G9D29fqrpM5ZkspMcPICud3XsBJQ4Y2URg8g==
has-bigints@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113"
@ -5895,6 +5900,13 @@ iconv-lite@^0.6.2:
dependencies:
safer-buffer ">= 2.1.2 < 3.0.0"
identity-obj-proxy@3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14"
integrity sha1-lNK9qWCERT7zb7xarsN+D3nx/BQ=
dependencies:
harmony-reflect "^1.4.6"
ignore-walk@^3.0.3:
version "3.0.4"
resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.4.tgz#c9a09f69b7c7b479a5d74ac1a3c0d4236d2a6335"
@ -6431,6 +6443,13 @@ jest-config@^27.3.1:
micromatch "^4.0.4"
pretty-format "^27.3.1"
jest-css-modules@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/jest-css-modules/-/jest-css-modules-2.1.0.tgz#9c25ebe9d0214d8f55861a442268fdd4b01b4781"
integrity sha512-my3Scnt6l2tOll/eGwNZeh1KLAFkNzdl4MyZRdpl46GO6/93JcKKdTjNqK6Nokg8A8rT84MFLOpY1pzqKBEqMw==
dependencies:
identity-obj-proxy "3.0.0"
jest-diff@^26.0.0:
version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394"