Skip to content

Commit

Permalink
fix(tsc-files): import @testing-library/jest-dom/jest-globals types i…
Browse files Browse the repository at this point in the history
…n jest setup files (#5178)
  • Loading branch information
calebpollman committed Apr 24, 2024
1 parent a431fe1 commit 3357620
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/react-geo/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const config: Config = {
moduleNameMapper: { '^uuid$': '<rootDir>/../../node_modules/uuid' },
modulePathIgnorePatterns: ['<rootDir>/dist/'],
preset: 'ts-jest',
setupFilesAfterEnv: ['./jest.setup.ts'],
testEnvironment: 'jsdom',
};

Expand Down
10 changes: 10 additions & 0 deletions packages/react-geo/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import '@testing-library/jest-dom/jest-globals';
import '@testing-library/jest-dom';

/**
* This is a workaround to the problem of the jsdom library not supporting
* URL.createObjectURL. See https://github.com/jsdom/jsdom/issues/1721.
*/
if (typeof window.URL.createObjectURL === 'undefined') {
window.URL.createObjectURL = jest.fn();
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import * as React from 'react';
import { Amplify, ResourcesConfig } from 'aws-amplify';
import { render } from '@testing-library/react';
import '@testing-library/jest-dom';

/**
* This is a workaround to the problem of the jsdom library not supporting
* URL.createObjectURL. See https://github.com/jsdom/jsdom/issues/1721.
*/
if (typeof window.URL.createObjectURL === 'undefined') {
window.URL.createObjectURL = jest.fn();
}

import { LocationSearch } from '..';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ import * as React from 'react';
import { Amplify, ResourcesConfig } from 'aws-amplify';
import { fetchAuthSession } from 'aws-amplify/auth';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
/**
* This is a workaround to the problem of the jsdom library not supporting
* URL.createObjectURL. See https://github.com/jsdom/jsdom/issues/1721.
*/
if (typeof window.URL.createObjectURL === 'undefined') {
window.URL.createObjectURL = jest.fn();
}

import { MapView } from '..';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-geo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@aws-amplify/typescript-config/tsconfig.react.json",
"include": ["jest.config.ts", "src/**/*.ts", "src/**/*.tsx"],
"include": ["jest.*.ts", "src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions packages/react-liveness/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@testing-library/jest-dom/jest-globals';
import '@testing-library/jest-dom';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react-liveness/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@aws-amplify/typescript-config/tsconfig.react.json",
"include": ["jest.config.ts", "jest.setup.ts", "src/**/*.ts", "src/**/*.tsx"],
"include": ["jest.*.ts", "src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions packages/react-notifications/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@testing-library/jest-dom/jest-globals';
import '@testing-library/jest-dom';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react-notifications/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@aws-amplify/typescript-config/tsconfig.react.json",
"include": ["jest.config.ts", "jest.setup.ts", "src/**/*.ts", "src/**/*.tsx"],
"include": ["jest.*.ts", "src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions packages/react-storage/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@testing-library/jest-dom/jest-globals';
import '@testing-library/jest-dom';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/react-storage/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@aws-amplify/typescript-config/tsconfig.react.json",
"include": ["jest.config.ts", "jest.setup.ts", "src/**/*.ts", "src/**/*.tsx"],
"include": ["jest.*.ts", "src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions packages/react/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@testing-library/jest-dom/jest-globals';
import '@testing-library/jest-dom';

/**
Expand Down

0 comments on commit 3357620

Please sign in to comment.