Skip to content

Commit

Permalink
Fix a problem with css-dev-only-do-not-override (antd) (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierfacq authored Sep 26, 2023
1 parent 9d664b1 commit c6984d4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`NavigationMenu component > renders correctly /download path 1`] = `
<div>
<ul
class="ant-menu ant-menu-root ant-menu-inline ant-menu-light css-dev-only-do-not-override-1vr7spz"
class="ant-menu ant-menu-root ant-menu-inline ant-menu-light"
data-menu-list="true"
role="menu"
style="height: 100%; border-right: 0; margin-top: 20px;"
Expand Down Expand Up @@ -83,7 +83,7 @@ exports[`NavigationMenu component > renders correctly /download path 1`] = `
exports[`NavigationMenu component > renders correctly /trends path 1`] = `
<div>
<ul
class="ant-menu ant-menu-root ant-menu-inline ant-menu-light css-dev-only-do-not-override-1vr7spz"
class="ant-menu ant-menu-root ant-menu-inline ant-menu-light"
data-menu-list="true"
role="menu"
style="height: 100%; border-right: 0; margin-top: 20px;"
Expand Down
2 changes: 0 additions & 2 deletions src/Components/NavigationMenu/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { vi, describe, expect, test } from 'vitest'
import NavigationMenu from '../index';
import { useLocation } from 'react-router-dom';

vi.mock('react-router-dom');

describe('NavigationMenu component', () => {
test('renders correctly /download path', async() => {
vi.mocked(useLocation).mockReturnValue({path: '/download'});
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"include": [
"**/*.{ts,tsx,mdx}",
"vitest.config.ts",
"vitest-setup.ts"
"vitest-setup.ts",
"vitest.config.ts"
]
}
41 changes: 10 additions & 31 deletions vitest-setup.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import fs from 'fs/promises';
import { vi } from 'vitest'

export default defineConfig({
esbuild: {
loader: "jsx",
include: /src\/.*\.jsx?$/,
exclude: [],
},
optimizeDeps: {
esbuildOptions: {
plugins: [
{
name: "load-js-files-as-jsx",
setup(build) {
build.onLoad({ filter: /src\\.*\.js$/ }, async (args) => ({ // i modified the regex here
loader: "jsx",
contents: await fs.readFile(args.path, "utf8"),
}));
},
},
],
},
},
plugins: [react()],
test: {
globals: true,
environment: 'jsdom',
setupFiles: './vitest-setup.ts'
}
})
// mock router for 'useParams'
vi.mock('react-router-dom');

vi.mock('antd', async () => {
const antd = await vi.importActual('antd');
// @ts-expect-error importActualの型付けをしていない
antd.theme.defaultConfig.hashed = false;
return antd;
});

0 comments on commit c6984d4

Please sign in to comment.