-
Notifications
You must be signed in to change notification settings - Fork 684
[SDK] Skip flaky tests #8942
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
[SDK] Skip flaky tests #8942
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,15 +43,13 @@ it("should resolve abi from contract api", async () => { | |
| expect(abi).toMatchObject(DOODLES_ABI); | ||
| }); | ||
|
|
||
| it.runIf(process.env.TW_SECRET_KEY)( | ||
| "should resolve abi from bytecode", | ||
| async () => { | ||
| it.runIf(process.env.TW_SECRET_KEY) | ||
| .skip("should resolve abi from bytecode", async () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
file="packages/thirdweb/src/contract/actions/resolve-abi.test.ts"
if rg -n 'it\.runIf\(process\.env\.TW_SECRET_KEY\)\s*\.skip\(' "$file"; then
echo "The bytecode ABI test is unconditionally skipped."
exit 1
fi
rg -n 'it\.skipIf\(!process\.env\.TW_SECRET_KEY\)|it\.runIf\(process\.env\.TW_SECRET_KEY\)' "$file"Repository: thirdweb-dev/js Length of output: 192 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
file="packages/thirdweb/src/contract/actions/resolve-abi.test.ts"
printf '%s\n' '--- test registration ---'
sed -n '35,60p' "$file"
printf '%s\n' '--- Vitest declarations and versions ---'
rg -n --glob 'package.json' --glob '*lock*' '"vitest"|vitest@' . | head -80Repository: thirdweb-dev/js Length of output: 4452 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
file="packages/thirdweb/src/contract/actions/resolve-abi.test.ts"
sed -n '40,58p' "$file"
rg -n --glob 'package.json' --glob '*lock*' '"vitest"|vitest@' . | head -80Repository: thirdweb-dev/js Length of output: 4213 🌐 Web query:
💡 Result: In Vitest 3.2.4, conditional test control is handled via two distinct mechanisms: static registration (before tests run) and dynamic execution (inside the test body) [1][2][3]. 1. Static Conditional Registration (Collection Phase) Use Citations:
🌐 Web query:
💡 Result: The runIf and skipIf APIs are conditional execution modifiers available in the Vitest test framework [1][2]. They allow you to control whether a test or suite runs based on a provided condition [3][2]. runIf(condition) The test or suite will only run if the provided condition evaluates to a truthy value [2]. If the condition is falsy, the test is skipped [2]. skipIf(condition) The test or suite will be skipped if the provided condition evaluates to a truthy value [2]. If the condition is falsy, the test proceeds as normal [2]. Key Details: - Usage: These methods can be chained with test or describe blocks, such as test.runIf(condition)(...) or describe.skipIf(condition)(...) [3][4]. - Conditions: The condition is evaluated during the test collection phase [3]. If you use a function as the condition, it is called at that time [3]. - Flexibility: These APIs are available on both individual tests and suites, providing a declarative way to manage environment-specific or state-dependent tests without requiring imperative if-else logic inside test bodies [3][2]. Citations:
<|DELIM_0G|>Use
🤖 Prompt for AI Agents |
||
| // we do this so we don't hit any PRIOR cache | ||
| const DOODLES_CONTRACT_CLONE = { ...DOODLES_CONTRACT }; | ||
| const abi = await resolveAbiFromBytecode(DOODLES_CONTRACT_CLONE); | ||
| expect(abi).toMatchObject(DOODLES_ABI); | ||
| }, | ||
| ); | ||
| }); | ||
|
|
||
| it("should throw error if contract bytecode is 0x", async () => { | ||
| const wrongContract = getContract({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: thirdweb-dev/js
Length of output: 21009
🤖 get_repo_knowledge executed:
get_repo_knowledge thirdweb-dev/js /tmp/coderabbit-repo-knowledge/thirdweb-dev-js-e0b0fe64/architecture /tmp/coderabbit-repo-knowledge/thirdweb-dev-js-e0b0fe64/conventionsLength of output: 36458
🌐 Web query:
Vitest 3.2.4 test.runIf skipIf API chaining runIf(condition).skip💡 Result:
In Vitest 3.2.4, the test.runIf and test.skipIf APIs are designed to conditionally execute or skip tests based on a provided boolean condition [1][2]. Regarding the chaining behavior: 1. Method Chaining: You can chain modifiers such as.skip,.concurrent,.runIf, and.skipIf [1][3]. For example, test.concurrent.skipIf(condition) is a valid pattern [1][2]. 2. Chaining Order: While you can combine these modifiers, they operate as distinct decorators on the test function [1][2]. You generally chain them to configure the test's behavior before defining the test body [1][4]. 3. Interaction of runIf and skipIf: While technically allowed by the type system, chaining both.runIf(condA).skipIf(condB) is redundant and typically discouraged because they are logical opposites [1][2]. If you need complex logic, it is cleaner to combine your conditions into a single boolean expression within one modifier (e.g., test.runIf(condA &&!condB)) rather than chaining both [1]. 4. Context and Fixtures: In earlier versions of Vitest, chaining.runIf or.skipIf could sometimes result in lost test context or fixtures [5]. However, this was specifically addressed in previous updates to ensure that the test object instance is preserved correctly throughout the method chain, maintaining access to fixtures and context [6][7]. In summary, while you can technically chain these methods, you should prioritize readability by using a single, combined conditional expression in one modifier rather than chaining.runIf and.skipIf together [1]. Ensure your conditions are correctly evaluated at the time the test suite is being collected by Vitest [1][8].
Citations:
Fix the shared Vitest gating pattern.
Appending
.skip(...)after.runIf(process.env.TW_SECRET_KEY)unconditionally skips each selected test or suite. These five tests remain skipped even whenTW_SECRET_KEYis set. Replace each registration withskipIf(!process.env.TW_SECRET_KEY).Proposed correction
📝 Committable suggestion
📍 Affects 5 files
packages/thirdweb/src/contract/actions/resolve-abi.test.ts#L46-L47(this comment)packages/thirdweb/src/extensions/airdrop/write/airdropERC721WithSignature.test.ts#L29-L31packages/thirdweb/src/extensions/erc1155/drop1155.test.ts#L34-L34packages/thirdweb/src/extensions/modules/ClaimableERC721/claimableERC721.test.ts#L21-L21packages/thirdweb/src/extensions/prebuilts/process-ref-deployments.test.ts#L11-L11🤖 Prompt for AI Agents
Source: MCP tools