fix: remove flakey tests from cloud functions and overall deflake (#7156)

* fix: remove flakey tests

* increase setup time

* reduce max workers

* Update .github/workflows/test.yml

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>

* Update functions/global-setup.ts

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>

* Update global-teardown.ts

* add retry time

---------

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
This commit is contained in:
Brendan Wong 2023-08-14 16:50:49 -04:00 committed by GitHub
parent 7cf768b8dd
commit 51dc10b467
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 8 additions and 6 deletions

@ -225,7 +225,8 @@ jobs:
path: node_modules/.cache
key: ${{ runner.os }}-cloud-jest-${{ github.run_id }}
restore-keys: ${{ runner.os }}-cloud-jest-
- run: yarn test:cloud --coverage --maxWorkers=100%
# Only use 1 worker, so the other can be used for the proxy server under test.
- run: yarn test:cloud --coverage --maxWorkers=1
pre:
if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }}

@ -10,7 +10,7 @@ test.each(assetImageUrl)('assetImageUrl', async (url) => {
})
const invalidAssetImageUrl = [
'http://127.0.0.1:3000/api/image/nfts/asset/0xed5af388653567af2f388e6224dc7c4b3241c544/100000',
'http://127.0.0.1:3000/api/image/nfts/asset/0xed5af388653567af2f388e6224dc7c4b3241c544/10001',
'http://127.0.0.1:3000/api/image/nfts/asset/0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d/44700',
]

@ -23,7 +23,7 @@ export const onRequest: PagesFunction = async ({ params, request }) => {
)
if (!data) {
return new Response('Asset not found.', { status: 404 })
return new Response('Collection not found.', { status: 404 })
}
const [fontData, palette] = await Promise.all([getFont(), getColor(data.ogImage)])

@ -25,7 +25,7 @@ export const onRequest: PagesFunction = async ({ params, request }) => {
)
if (!data) {
return new Response('Asset not found.', { status: 404 })
return new Response('Token not found.', { status: 404 })
}
const [fontData, palette] = await Promise.all([getFont(), getColor(data.ogImage)])

@ -13,7 +13,6 @@ const invalidTokenImageUrl = [
'http://127.0.0.1:3000/api/image/tokens/ethereum/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb49',
'http://127.0.0.1:3000/api/image/tokens/ethereum',
'http://127.0.0.1:3000/api/image/tokens/ethereun',
'http://127.0.0.1:3000/api/image/tokens/ethereum/0x0',
'http://127.0.0.1:3000/api/image/tokens/potato/?potato=1',
]

@ -4,7 +4,7 @@ module.exports = async function globalSetup() {
globalThis.servers = await setup({
command: `yarn start:cloud`,
port: 3000,
launchTimeout: 80000,
launchTimeout: 120000, // takes ~2m on CI
})
// Wait for wrangler to return a request before running tests
for (let i = 0; i < 3; i++) {

@ -1,6 +1,7 @@
{
"globalSetup": "<rootDir>/global-setup.ts",
"globalTeardown": "<rootDir>/global-teardown.ts",
"setupFilesAfterEnv": ["<rootDir>/setupAfterEnv.ts"],
"preset": "ts-jest",
"transform": {
"'^.+\\.(ts|tsx)?$'": "ts-jest",

@ -0,0 +1 @@
jest.retryTimes(3)