UNPKG

@zohodesk/components

Version:

Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development

107 lines (91 loc) 3.72 kB
const path = require('path'); // Notes for future maintainers: // - @zohodesk/unit-testing-framework runs `JSON.stringify(config)` before // handing this to Jest, so every value here must be JSON-serializable // (no functions, no live RegExp objects — patterns are strings). // - The framework REPLACES its default config with this file when present // (despite the "Merging..." log line in config-loader.js), so this file // must be self-contained. // `@zohodesk/unit-testing-framework/package.json` isn't in its exports map, // so resolve via the main entry (points to build/index.js) and step up. const FRAMEWORK_BUILD = path.dirname( require.resolve('@zohodesk/unit-testing-framework') ); // Pin Jest 30's jsdom env — bare "jsdom" can resolve to Jest 26/27 copies // pulled in by react-cli / react-scripts, which crash under Jest 30. const JEST_JSDOM_ENV = require.resolve('jest-environment-jsdom', { paths: [require.resolve('@zohodesk/unit-testing-framework')] }); module.exports = { rootDir: __dirname, roots: ['<rootDir>/src'], testEnvironment: JEST_JSDOM_ENV, testMatch: [ '<rootDir>/src/**/__tests__/**/*.(spec|test).[jt]s?(x)', '<rootDir>/src/**/?(*.)+(spec|test).[jt]s?(x)' ], testPathIgnorePatterns: [ '/node_modules/', '/build/', '/lib/', '/es/', '/dist/', '/coverage/', '/unittest/' ], moduleFileExtensions: ['js', 'jsx', 'mjs', 'cjs', 'json', 'ts', 'tsx', 'node'], transform: { // Absolute paths — the framework JSON.stringifies this config before Jest // resolves transforms, so bare package names can point at a missing nested // copy under unit-testing-framework/node_modules. '^.+\\.[jt]sx?$': [ require.resolve('babel-jest'), { presets: [ [require.resolve('@babel/preset-env'), { targets: { node: 'current' } }], [require.resolve('@babel/preset-react'), { runtime: 'classic' }] ] } ], '^.+\\.(svg|png|jpg|jpeg|gif|webp|woff2?|ttf|eot|otf|mp4|webm)$': '<rootDir>/__testUtils__/fileTransform.js', // Enumerable class-name map (not identity-obj-proxy) — mergeStyle spreads // the style object, which yields {} for a non-enumerable Proxy. '^.+\\.(css|less|scss|sass)$': '<rootDir>/__testUtils__/cssModulesTransform.js' }, // @zohodesk/* and @dot-system/* ship untranspiled ESM in some places, so // let babel-jest transform them. transformIgnorePatterns: [ '/node_modules/(?!(@zohodesk|@zohodesk-private|@dot-system)/)' ], moduleNameMapper: { // Prefer the ES build for @zohodesk libraries (mirrors react-cli's libAlias). '^@zohodesk/(components|dot|icons|svg|variables|virtualizer|hooks|utils|a11y|layout|dotkit)/lib(.*)$': '@zohodesk/$1/es$2' }, // Injects `jest` on globalThis so tests that don't `import { jest }` from // '@jest/globals' still work under the framework's runner. before run setupFiles: [ path.join(FRAMEWORK_BUILD, 'src', 'environment', 'globals-inject.js') ], // Existing test bootstrap: @testing-library/react configure, ResizeObserver // mock, requestAnimationFrame shim, className `cn` wrapper on React.createElement. setupFilesAfterEnv: [ '<rootDir>/__testUtils__/globals.js', '@testing-library/jest-dom' ], clearMocks: true, passWithNoTests: true, testTimeout: 20000, // Coverage tuning (used only when `--coverage` is passed). collectCoverageFrom: [ 'src/**/*.{js,jsx,ts,tsx}', '!src/**/__tests__/**', '!src/**/*.spec.{js,jsx,ts,tsx}', '!src/**/*.test.{js,jsx,ts,tsx}', '!src/**/index.js' ], coverageDirectory: 'coverage', coverageReporters: ['json', 'json-summary', 'text', 'html'] };