Skip to content

Commit

Permalink
fix(react): restore missing types from lib (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
scurker authored and anastasialanz committed Feb 25, 2024
1 parent fdeac72 commit 4e6294d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/react/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
plugins: ['ssr-friendly'],
overrides: [
{
files: ['__tests__/**/*', '**/*.test.[j|t]sx?'],
files: ['__tests__/**/*', '**/*.test.[j|t]sx?', 'src/setupTests.ts'],
rules: {
'ssr-friendly/no-dom-globals-in-module-scope': 'off',
'ssr-friendly/no-dom-globals-in-constructor': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/react/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Config } from 'jest';

const config: Config = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/__tests__/setupTests.ts'],
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
testMatch: [
'**/__tests__/src/**/*.js',
'**/__tests__/demo/**/*.js',
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"scripts": {
"build": "yarn build:lib && yarn build:css",
"prebuild:lib": "node scripts/buildIconTypes.js",
"build:lib": "rollup -c && tsc --declaration --emitDeclarationOnly --outDir lib",
"build:lib": "rollup -c",
"build:css": "postcss --output=lib/cauldron.css src/index.css",
"dev": "concurrently 'yarn build:css --watch' 'rollup -c --watch'",
"prepublishOnly": "NODE_ENV=production yarn build",
Expand Down
11 changes: 10 additions & 1 deletion packages/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,16 @@ export default {
chunkFileNames: '[name].js'
},
plugins: [
typescript(),
typescript({
tsconfig: './tsconfig.json',
exclude: [
'./__tests__',
'**.test.ts',
'**.test.tsx',
'./src/setupTests.ts',
'./src/axe.ts'
]
}),
commonjs(),
svgr({
svgoConfig: {
Expand Down
25 changes: 25 additions & 0 deletions packages/react/src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* global window */
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import '@testing-library/jest-dom';
import 'jest-axe/extend-expect';
import { configureAxe } from 'jest-axe';

configure({ adapter: new Adapter() });
configureAxe({
rules: {
region: { enabled: false }
}
});

if (
!Object.getOwnPropertyDescriptor(window.HTMLElement.prototype, 'innerText')
) {
// JSDOM doesn't fully support innerText, but we can fall back to
// using textContent for now until this gets patched
Object.defineProperty(window.HTMLElement.prototype, 'innerText', {
get() {
return this.textContent;
}
});
}
6 changes: 4 additions & 2 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*", "__tests__/setupTests.ts"],
"include": ["src/**/*"],
"exclude": ["node_modules"],
"compilerOptions": {
"skipLibCheck": true
"skipLibCheck": true,
"declarationDir": "lib",
"declaration": true
}
}

0 comments on commit 4e6294d

Please sign in to comment.