feat: wrangler infra and test environment (#6797)

* feat: add token and nft injection

* feat: basic tests

* fix: get jest configured properly

* fix: change timeout

* fix: uninstall port ready

* fix: readd port ready

* fix: local tests work

* fix: remove other stuff to make this pr smaller

* fix: remove unneeded dependencies

* fix: remove port-ready

* Update yarn.lock

* fix: add lint disable due to module exports for jest

* fix: added waitPort

* fix: deduplicated things?

* Update package.json

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

* update typing

* change tests to typescript instead of javascript

* changing typing of globalThis servers

* yarn deduplicate

* Update functions/global-teardown.ts

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

* Update functions/global.d.ts

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

* Update functions/tsconfig.json

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

* Update functions/tsconfig.json

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

* Update package.json

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

* change dependencies to dev dependencies

* final touches

---------

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
This commit is contained in:
Brendan Wong 2023-07-07 11:41:09 -04:00 committed by GitHub
parent bcb45cded6
commit ef5065de48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 2292 additions and 636 deletions

@ -0,0 +1 @@
export const presets = ['@babel/preset-env']

@ -0,0 +1,9 @@
import { setup } from 'jest-dev-server'
module.exports = async function globalSetup() {
globalThis.servers = await setup({
command: `yarn start:cloud`,
port: 3000,
launchTimeout: 50000,
})
}

@ -0,0 +1,5 @@
import { teardown } from 'jest-dev-server'
module.exports = async function globalTeardown() {
await teardown(globalThis.servers)
}

6
functions/global.d.ts vendored Normal file

@ -0,0 +1,6 @@
import { setup } from 'jest-dev-server'
declare global {
// eslint-disable-next-line no-var
var servers: Awaited<ReturnType<typeof setup>>
}

@ -0,0 +1,9 @@
{
"globalSetup": "<rootDir>/global-setup.ts",
"globalTeardown": "<rootDir>/global-teardown.ts",
"preset": "ts-jest",
"transform": {
"'^.+\\.(ts|tsx)?$'": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest"
}
}

3
functions/nft.test.ts Normal file

@ -0,0 +1,3 @@
test('example', async () => {
expect(true).toBe(true)
})

19
functions/tsconfig.json Normal file

@ -0,0 +1,19 @@
{
"compilerOptions": {
"esModuleInterop": true,
"incremental": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"noEmit": true,
"strict": true,
"target": "ES6",
"tsBuildInfoFile": "../node_modules/.cache/tsbuildinfo/functions", // avoid clobbering the build tsbuildinfo
"types": ["jest", "node"],
"jsx": "react",
"moduleResolution": "NodeNext",
},
"exclude": ["node_modules"],
"include": ["**/*.ts"],
"watchOptions": {
"excludeDirectories": ["node_modules"]
}
}

@ -19,6 +19,7 @@
"i18n": "yarn i18n:extract --clean && yarn i18n:compile",
"prepare": "concurrently \"npm:ajv\" \"npm:contracts\" \"npm:graphql\" \"npm:i18n\"",
"start": "craco start",
"start:cloud": "NODE_OPTIONS=--dns-result-order=ipv4first PORT=3001 npx wrangler pages dev --proxy=3001 --port=3000 -- yarn start",
"build": "craco build",
"build:e2e": "REACT_APP_CSP_ALLOW_UNSAFE_EVAL=true REACT_APP_ADD_COVERAGE_INSTRUMENTATION=true craco build",
"analyze": "source-map-explorer 'build/static/js/*.js' --only-mapped",
@ -26,6 +27,7 @@
"lint": "yarn eslint --ignore-path .gitignore --cache --cache-location node_modules/.cache/eslint/ .",
"typecheck": "tsc",
"test": "craco test",
"test:cloud": "NODE_OPTIONS=--experimental-vm-modules yarn jest functions --watch --config=functions/jest.config.json",
"cypress:open": "cypress open --browser chrome --e2e",
"cypress:run": "cypress run --browser chrome --e2e",
"deduplicate": "yarn-deduplicate --strategy=highest"
@ -66,6 +68,8 @@
]
},
"devDependencies": {
"@babel/preset-env": "^7.22.7",
"@cloudflare/workers-types": "^4.20230518.0",
"@craco/craco": "^7.1.0",
"@ethersproject/experimental": "^5.4.0",
"@lingui/cli": "^3.9.0",
@ -103,6 +107,7 @@
"@vanilla-extract/jest-transform": "^1.1.1",
"@vanilla-extract/webpack-plugin": "^2.1.11",
"@walletconnect/types": "^2.8.6",
"babel-jest": "^29.6.1",
"babel-plugin-istanbul": "^6.1.1",
"buffer": "^6.0.3",
"concurrently": "^8.0.1",
@ -113,6 +118,8 @@
"eslint-plugin-import": "^2.27",
"eslint-plugin-rulesdir": "^0.2.2",
"hardhat": "^2.14.0",
"jest": "^29.6.1",
"jest-dev-server": "^9.0.0",
"jest-fail-on-console": "^3.1.1",
"jest-fetch-mock": "^3.0.3",
"jest-styled-components": "^7.0.8",
@ -124,9 +131,11 @@
"resize-observer-polyfill": "^1.5.1",
"serve": "^11.3.2",
"source-map-explorer": "^2.5.3",
"ts-jest": "^29.1.1",
"ts-transform-graphql-tag": "^0.2.1",
"typechain": "^5.0.0",
"typescript": "^4.4.3",
"wrangler": "https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/4925945367/npm-package-wrangler-3048",
"webpack-retry-chunk-load-plugin": "^3.1.1",
"yarn-deduplicate": "^6.0.0"
},

2867
yarn.lock

File diff suppressed because it is too large Load Diff