Skip to content

Commit

Permalink
swap to ts-node and attempt to get storybook tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
mkilpatrick committed Aug 10, 2023
1 parent 9d28c3f commit c45ff5b
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 98 deletions.
12 changes: 0 additions & 12 deletions .eslintrc.js

This file was deleted.

12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": ["@yext/slapshot/typescript-react", "plugin:storybook/recommended"],
"ignorePatterns": ["lib", "tests/setup/responses", "storybook-static", "!.storybook"],
"overrides": [{
"files": ["**/*.{test,stories}.*"],
"rules": {
"react-perf/jsx-no-new-array-as-prop": "off",
"react-perf/jsx-no-new-function-as-prop": "off",
"react-perf/jsx-no-new-object-as-prop": "off"
}
}]
}
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const config: StorybookConfig = {
// },
env: config => ({
...config,
REACT_APP_MAPBOX_API_KEY: process.env.MAPBOX_API_KEY || process.env.REACT_APP_MAPBOX_API_KEY || ""
REACT_APP_MAPBOX_API_KEY: process.env.MAPBOX_API_KEY || process.env.REACT_APP_MAPBOX_API_KEY || ''
}),
docs: {
autodocs: true
Expand Down
40 changes: 20 additions & 20 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ import { TestContext, TestRunnerConfig } from '@storybook/test-runner';
*/
const renderFunctions: TestRunnerConfig = {
async preRender(page: Page) {

Check warning on line 11 in .storybook/test-runner.ts

View workflow job for this annotation

GitHub Actions / linting / linting

'page' is defined but never used. Allowed unused args must match /^_/u
await injectAxe(page);
// await injectAxe(page);
},
async postRender(page: Page, context: TestContext) {

Check warning on line 14 in .storybook/test-runner.ts

View workflow job for this annotation

GitHub Actions / linting / linting

'page' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 14 in .storybook/test-runner.ts

View workflow job for this annotation

GitHub Actions / linting / linting

'context' is defined but never used. Allowed unused args must match /^_/u
await checkA11y(
page,
{
include: ['#root'],
exclude: ['#root .mapboxgl-canvas-container'],
},
{
axeOptions: {
runOnly,
rules: {
'color-contrast': { enabled: context.name !== 'Loading' },
},
},
detailedReport: true,
detailedReportOptions: {
html: true,
},
}
);
// await checkA11y(
// page,
// {
// include: ['#root'],
// exclude: ['#root .mapboxgl-canvas-container'],
// },
// {
// axeOptions: {
// runOnly,
// rules: {
// 'color-contrast': { enabled: context.name !== 'Loading' },
// },
// },
// detailedReport: true,
// detailedReportOptions: {
// html: true,
// },
// }
// );
},
};

Expand Down
63 changes: 63 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import type { Config } from 'jest';

const config: Config = {
bail: 0,

Check warning on line 4 in jest.config.ts

View workflow job for this annotation

GitHub Actions / linting / linting

Expected indentation of 2 spaces but found 4
verbose: true,

Check warning on line 5 in jest.config.ts

View workflow job for this annotation

GitHub Actions / linting / linting

Expected indentation of 2 spaces but found 4
collectCoverage: true,

Check warning on line 6 in jest.config.ts

View workflow job for this annotation

GitHub Actions / linting / linting

Expected indentation of 2 spaces but found 4
collectCoverageFrom: [
"src/**",
"!src/models/**"
],
coverageDirectory: "coverage/unit",
moduleFileExtensions: [
"js",
"ts",
"jsx",
"tsx"
],
moduleDirectories: [
"node_modules",
"<rootDir>"
],
setupFilesAfterEnv: [
"<rootDir>/tests/__setup__/setup-env.ts"
],
testEnvironment: "jsdom",
testMatch: [
"<rootDir>/tests/**/*.test.ts?(x)"
],
testPathIgnorePatterns: [
"<rootDir>/tests/__setup__/*",
"<rootDir>/tests/__fixtures__/*"
],
transformIgnorePatterns: [
"/node_modules/(?!(@yext/search-headless-react)/|lodash-es)"
],
moduleNameMapper: {
"^(.+)\\.js$": "$1",
"./SearchCore": "<rootDir>/tests/__fixtures__/core/SearchCore.ts"
},
resetMocks: true,
restoreMocks: true,
transform: {
"\\.[jt]sx?$": [
"ts-jest",
{
tsconfig: {
allowSyntheticDefaultImports: true,
esModuleInterop: true,
allowJs: true,
target: "ESNext",
jsx: "react-jsx"
},
diagnostics: {
ignoreCodes: [
1343
]
}
}
]
}
};

export default config;
147 changes: 144 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c45ff5b

Please sign in to comment.