Skip to content

Commit

Permalink
fix(packages/gqty): transform ESM packages in jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed May 1, 2024
1 parent a12960e commit 1244c26
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
10 changes: 4 additions & 6 deletions internal/test-utils/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ const moduleNameMapper = pathsToModuleNameMapper(compilerOptions.paths, {

process.env.TS_JEST_HOOKS = require.resolve('./tsJestHooks.js');

/**
* @type {import("@jest/types").Config.InitialOptions}
*/
/** @type {import('ts-jest').JestConfigWithTsJest} */
const defaultConfig = {
preset: 'ts-jest',
transform: {
'\\.[jt]sx?$': [
'ts-jest',
{
tsconfig: require.resolve('./test/tsconfig.json'),
isolatedModules: true,
useESM: true,
},
],
},
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],
transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\](?!p-lazy)\\.[jt]sx?$'],
modulePathIgnorePatterns: ['/dist/'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testEnvironment: 'node',
Expand All @@ -31,7 +29,7 @@ const defaultConfig = {
testPathIgnorePatterns: ['/node_modules/', '/test/generated'],
collectCoverage: true,
collectCoverageFrom: ['./src/**/*.ts', './src/**/*.tsx', '!**/*.d.ts'],
testTimeout: 10000,
testTimeout: 30_000,
watchPlugins: [
require.resolve('jest-watch-typeahead/filename'),
require.resolve('jest-watch-typeahead/testname'),
Expand Down
7 changes: 4 additions & 3 deletions internal/test-utils/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"allowJs": true,
"target": "esnext",
"module": "esnext",
"strict": true,
"esModuleInterop": true,
"jsx": "react"
"jsx": "react-jsx"
},
"include": ["**/*.ts", "**/*.tsx"]
}
2 changes: 1 addition & 1 deletion packages/gqty/src/Client/compat/subscriptionsClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { createDeferredIterator } from 'gqty/Utils/deferred';
import type { ExecutionResult } from 'graphql';
import type {
Client,
Expand All @@ -11,6 +10,7 @@ import type {
SubscribePayload,
} from 'graphql-ws';
import { GQtyError } from '../../Error';
import { createDeferredIterator } from '../../Utils/deferred';
import type { LegacySelection as Selection } from './selection';

type Promisable<T> = T | Promise<T>;
Expand Down
2 changes: 1 addition & 1 deletion packages/gqty/test/cache.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertIsDefined } from 'test-utils';
import { $meta, createSchemaAccessor } from '../src/Accessor';
import { createObjectAccessor } from '../src/Accessor/resolve';
import { Cache, CacheRoot } from '../src/Cache';
import { Cache, type CacheRoot } from '../src/Cache';
import { Selection } from '../src/Selection';

describe('Cache#dataAccessors', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = require('test-utils/jest.config.js').getConfig({
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
setupFiles: ['./jest.setup.ts'],
testEnvironment: 'jsdom',
testEnvironment: 'jest-environment-jsdom',
});

0 comments on commit 1244c26

Please sign in to comment.