8000 Update to Jest 30.0.2 by steveluscher · Pull Request #561 · anza-xyz/kit · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update to Jest 30.0.2 #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: graphite-base/561
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
"@eslint/js": "^9.28.0",
"@eslint/json": "^0.12.0",
"@solana/build-scripts": "workspace:*",
"@solana/eslint-config-solana": "^4.0.0",
"@solana/eslint-config-solana": "^5.0.0",
"@solana/prettier-config-solana": "0.0.5",
"@solana/test-config": "workspace:*",
"@solana/test-matchers": "workspace:*",
"@solana/tsconfig": "workspace:*",
"@swc/jest": "^0.2.38",
"@types/jest": "^29.5.14",
"@types/jest": "^30.0.0",
"@types/node": "^24",
"@typescript-eslint/eslint-plugin": "^8.32.1",
"@typescript-eslint/parser": "^8.33.1",
Expand All @@ -34,8 +34,8 @@
"eslint-plugin-simple-import-sort": "^12.1.1",
"e 10000 slint-plugin-sort-keys-fix": "^1.1.2",
"eslint-plugin-typescript-sort-keys": "^3.3.0",
"jest": "^30.0.0-alpha.6",
"jest-environment-jsdom": "^30.0.0-alpha.6",
"jest": "^30.0.0",
"jest-environment-jsdom": "^30.0.0",
"jest-runner-eslint": "^2.2.1",
"jest-runner-prettier": "^1.0.0",
"jest-watch-master": "^1.0.0",
Expand Down Expand Up @@ -69,7 +69,8 @@
"shelljs": ">=0.8.5"
},
"patchedDependencies": {
"jest-runner-prettier@1.0.0": "patches/jest-runner-prettier@1.0.0.patch"
"jest-runner-prettier@1.0.0": "patches/jest-runner-prettier@1.0.0.patch",
"expect@30.0.2": "patches/expect@30.0.2.patch"
}
},
"prettier": "@solana/prettier-config-solana"
Expand Down
125 changes: 125 additions & 0 deletions packages/build-scripts/tsup.config.package.bundled_dmwzk3idr47.mjs

Large diffs are not rendered by default.

53 changes: 37 additions & 16 deletions packages/errors/src/__tests__/error-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,46 @@ describe('SolanaError', () => {
expect(errorWithCause.cause).toBe(cause);
});
});
describe.each(['cause'])('given an error with only the `%s` property from `ErrorOptions` present', propName => {
describe.each(['cause'])('given an error with the `%s` property from `ErrorOptions` present', propName => {
let errorOptionValue: unknown;
let errorWithOption: SolanaError;
beforeEach(() => {
errorOptionValue = Symbol();
errorWithOption = new SolanaError(
// @ts-expect-error Mock error codes don't conform to `SolanaErrorCode`
123,
{ [propName]: errorOptionValue },
);
describe('as the only property', () => {
beforeEach(() => {
errorOptionValue = Symbol();
errorWithOption = new SolanaError(
// @ts-expect-error Mock error codes don't conform to `SolanaErrorCode`
123,
{ [propName]: errorOptionValue },
);
});
it('omits the error option from its context', () => {
expect(errorWithOption.context).not.toHaveProperty(propName);
});
it('calls the message formatter with the error option omitted', () => {
expect(getErrorMessage).toHaveBeenCalledWith(123, undefined);
});
});
it('omits the error option from its context', () => {
expect(errorWithOption.context).not.toHaveProperty(propName);
});
it('calls the message formatter with the error option omitted', () => {
expect(getErrorMessage).toHaveBeenCalledWith(
123,
expect.not.objectContaining({ [propName]: errorOptionValue }),
);
describe('as one among other properties', () => {
beforeEach(() => {
errorOptionValue = Symbol();
errorWithOption = new SolanaError(
// @ts-expect-error Mock error codes don't conform to `SolanaErrorCode`
123,
{
other: 'prop',
[propName]: errorOptionValue,
},
);
});
it('omits the error option from its context', () => {
expect(errorWithOption.context).not.toHaveProperty(propName);
});
it('calls the message formatter with the error option omitted', () => {
expect(getErrorMessage).toHaveBeenCalledWith(
123,
expect.not.objectContaining({ [propName]: errorOptionValue }),
);
});
});
});
it('sets its message to the output of the message formatter', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/test-config/browser-environment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { TestEnvironment } from 'jest-environment-jsdom';
import { protectProperties } from 'jest-util';

export default class BrowserEnvironment extends TestEnvironment {
async setup() {
Expand All @@ -9,5 +10,6 @@ export default class BrowserEnvironment extends TestEnvironment {
* https://github.com/jestjs/jest/issues/7780#issuecomment-615890410
*/
this.global.Uint8Array = globalThis.Uint8Array;
protectProperties(this.global['Uint8Array']);
}
}
1 change: 0 additions & 1 deletion packages/test-config/jest-unit.config.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const config: Partial<Config.InitialProjectOptions> = {
path.resolve(__dirname, 'setup-whatwg-fetch.ts'),
],
testEnvironment: path.resolve(__dirname, 'browser-environment.ts'),
testEnvironmentOptions: {},
testPathIgnorePatterns: [...(commonConfig.testPathIgnorePatterns ?? []), '-test.node.ts$'],
};

Expand Down
3 changes: 3 additions & 6D4E ; 0 deletions packages/test-config/jest-unit.config.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const config: Partial<Config.InitialProjectOptions> = {
path.resolve(__dirname, 'setup-define-version-constant.ts'),
path.resolve(__dirname, 'setup-webcrypto.ts'),
],
testEnvironmentOptions: {
globalsCleanup: 'on',
},
testPathIgnorePatterns: ['__setup__.ts'],
transform: {
'^.+\\.(ts|js)x?$': [
Expand Down
1 change: 1 addition & 0 deletions packages/test-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"devDependencies": {
"@jest/types": "^29.6.3",
"jest-util": "^30.0.0",
"undici": "^7.10.0",
"whatwg-fetch": "^3.6.20"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/test-config/setup-text-encoder.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { protectProperties } from 'jest-util';
import { TextDecoder, TextEncoder } from 'util';

if (typeof globalThis.TextEncoder === 'undefined') {
globalThis.TextEncoder = TextEncoder;
protectProperties(globalThis['TextEncoder']);
}

if (typeof globalThis.TextDecoder === 'undefined') {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
globalThis.TextDecoder = TextDecoder;
protectProperties(globalThis['TextDecoder']);
}
2 changes: 2 additions & 0 deletions packages/test-config/setup-undici-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { protectProperties } from 'jest-util';
import { fetch as undiciFetch } from 'undici';

globalThis.fetch = undiciFetch as unknown as typeof globalThis.fetch;
protectProperties(globalThis['fetch']);
4 changes: 4 additions & 0 deletions packages/test-config/setup-webcrypto.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import crypto from 'node:crypto';

import { protectProperties } from 'jest-util';

if (typeof globalThis.crypto === 'undefined') {
Object.defineProperty(globalThis, 'crypto', {
value: crypto.webcrypto,
writable: true, // Allow tests to delete it.
});
protectProperties(globalThis['crypto']);
}
if (typeof globalThis.crypto.subtle === 'undefined') {
Object.defineProperty(globalThis.crypto, 'subtle', {
value: crypto.webcrypto.subtle,
});
protectProperties(globalThis['crypto']['subtle']);
}
17 changes: 17 additions & 0 deletions patches/expect@30.0.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/build/index.js b/build/index.js
index d3b8c6792cac5d7690809791ee5a67b0310df478..10e869733cd630af55d2380952570cca20c5b329 100644
--- a/build/index.js
+++ b/build/index.js
@@ -1983,7 +1983,11 @@ function createMessageAndCause(error) {
if (seen.has(value)) return;
seen.add(value); // stop circular references
}
- return value === undefined ? String(undefined) : value;
+ return value === undefined
+ ? String(undefined)
+ : typeof value === 'bigint'
+ ? `${value.toString()}n`
+ : value;
Comment on lines +9 to +14
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
}
return error.message;
Loading
Loading
0