├── tsconfig.json ├── README.md ├── schema.graphql ├── src ├── schema.ts ├── app.ts ├── constants.ts └── graphql │ └── index.ts ├── .eslintrc.js ├── package.json ├── test └── index.test.ts ├── .gitignore ├── nexus-typegen.ts └── jest.config.ts /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "esModuleInterop": true, 5 | "target": "es6", 6 | "moduleResolution": "node", 7 | "sourceMap": true, 8 | "outDir": "dist" 9 | }, 10 | "lib": ["es2015"] 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## GraphQL approval testing 2 | 3 | To get started, clone the project, and run `npm i`. 4 | 5 | **If you change the `src/graphql/index.ts` schema, run `npm run gql` to re-generate the nexus schema.** 6 | 7 | If you wish to run the tests, run `npm test`, to develop, use `npm run dev`. 8 | -------------------------------------------------------------------------------- /schema.graphql: -------------------------------------------------------------------------------- 1 | ### This file was generated by Nexus Schema 2 | ### Do not make changes to this file directly 3 | 4 | 5 | type Query { 6 | hasApproved( 7 | """ENS / EOA address""" 8 | address: String! 9 | 10 | """ERC721 address""" 11 | collection: String! 12 | ): Boolean 13 | } -------------------------------------------------------------------------------- /src/schema.ts: -------------------------------------------------------------------------------- 1 | import { makeSchema } from 'nexus'; 2 | import { join } from 'path'; 3 | import * as types from './graphql'; 4 | 5 | export const schema = makeSchema({ 6 | types, 7 | outputs: { 8 | schema: join(process.cwd(), "schema.graphql"), 9 | typegen: join(process.cwd(), "nexus-typegen.ts"), 10 | }, 11 | }) -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "env": { 3 | "browser": true, 4 | "es2021": true 5 | }, 6 | "extends": [ 7 | "eslint:recommended", 8 | "plugin:@typescript-eslint/recommended" 9 | ], 10 | "parser": "@typescript-eslint/parser", 11 | "parserOptions": { 12 | "ecmaVersion": "latest", 13 | "sourceType": "module" 14 | }, 15 | "plugins": [ 16 | "@typescript-eslint" 17 | ], 18 | "rules": { 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-approval", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/app.js", 6 | "scripts": { 7 | "start": "tsc && node dist/app.js", 8 | "lint": "eslint . --ext .ts", 9 | "test": "NODE_ENV=test jest", 10 | "gql": "ts-node --transpile-only src/schema", 11 | "dev": "ts-node-dev --transpile-only --no-notify --exit-child src/app.ts" 12 | }, 13 | "keywords": [], 14 | "author": "", 15 | "license": "ISC", 16 | "devDependencies": { 17 | "@types/jest": "^27.5.0", 18 | "@typescript-eslint/eslint-plugin": "^5.23.0", 19 | "@typescript-eslint/parser": "^5.23.0", 20 | "eslint": "^8.15.0", 21 | "jest": "^28.1.0", 22 | "ts-jest": "^28.0.2", 23 | "ts-node-dev": "^1.1.8", 24 | "typescript": "^4.6.4" 25 | }, 26 | "dependencies": { 27 | "apollo-server-core": "^3.7.0", 28 | "apollo-server-express": "^3.7.0", 29 | "ethers": "^5.6.5", 30 | "ethers-multicall": "^0.2.3", 31 | "express": "^4.18.1", 32 | "graphql": "^16.5.0", 33 | "nexus": "^1.3.0" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/app.ts: -------------------------------------------------------------------------------- 1 | import { ApolloServer } from 'apollo-server-express'; 2 | import { ApolloServerPluginDrainHttpServer } from 'apollo-server-core'; 3 | import express from 'express'; 4 | import http from 'http'; 5 | import {schema} from './schema'; 6 | import { ethers } from 'ethers'; 7 | import { Provider } from 'ethers-multicall'; 8 | 9 | export const provider = new ethers.providers.CloudflareProvider(); 10 | export const multiCallProvider = new Provider(provider); 11 | 12 | export async function startServer() { 13 | await multiCallProvider.init(); 14 | 15 | const app = express(); 16 | const httpServer = http.createServer(app); 17 | const server = new ApolloServer({ 18 | schema: schema, 19 | csrfPrevention: true, 20 | plugins: [ApolloServerPluginDrainHttpServer({ httpServer })] 21 | }); 22 | 23 | await server.start(); 24 | server.applyMiddleware({ app }); 25 | if (process.env.NODE_ENV !== 'test') { 26 | httpServer.listen(4000, () => { 27 | console.log(`Running at http://localhost:4000${server.graphqlPath}`); 28 | }); 29 | } 30 | return server; 31 | } 32 | 33 | startServer(); -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export const ERC721_ID = "0x80ac58cd"; 2 | 3 | export const erc721abi = 4 | [ 5 | { 6 | "constant": true, 7 | "inputs": [ 8 | { 9 | "internalType": "address", 10 | "name": "owner", 11 | "type": "address" 12 | }, 13 | { 14 | "internalType": "address", 15 | "name": "operator", 16 | "type": "address" 17 | } 18 | ], 19 | "name": "isApprovedForAll", 20 | "outputs": [ 21 | { 22 | "internalType": "bool", 23 | "name": "", 24 | "type": "bool" 25 | } 26 | ], 27 | "payable": false, 28 | "stateMutability": "view", 29 | "type": "function" 30 | }, 31 | { 32 | "constant": true, 33 | "inputs": [ 34 | { 35 | "internalType": "bytes4", 36 | "name": "interfaceId", 37 | "type": "bytes4" 38 | } 39 | ], 40 | "name": "supportsInterface", 41 | "outputs": [ 42 | { 43 | "internalType": "bool", 44 | "name": "", 45 | "type": "bool" 46 | } 47 | ], 48 | "payable": false, 49 | "stateMutability": "view", 50 | "type": "function" 51 | } 52 | ] 53 | ; -------------------------------------------------------------------------------- /test/index.test.ts: -------------------------------------------------------------------------------- 1 | import { startServer } from '../src/app'; 2 | 3 | describe('GraphQL test', function () { 4 | let server; 5 | 6 | beforeAll(async function() { 7 | server = await startServer(); 8 | }) 9 | 10 | it("should try to resolve with a fake ens name", async function () { 11 | const result = await server.executeOperation({ 12 | query: 'query Query($address: String!, $collection: String!) { hasApproved(address: $address, collection: $collection) }', 13 | variables: { address: 'erosembergfake.eth', collection: '0x23581767a106ae21c074b2276d25e5c3e136a68b' } 14 | }); 15 | expect(result.errors).not.toBeUndefined(); 16 | }); 17 | 18 | it("should check a non ERC721 collection", async function () { 19 | const result = await server.executeOperation({ 20 | query: 'query Query($address: String!, $collection: String!) { hasApproved(address: $address, collection: $collection) }', 21 | variables: { address: '0x54BE3a794282C030b15E43aE2bB182E14c409C5e', collection: '0x495f947276749ce646f68ac8c248420045cb7b5e' } 22 | }); 23 | 24 | expect(result.errors).not.toBeUndefined(); 25 | }); 26 | 27 | it("should check a non approved collection", async function () { 28 | const result = await server.executeOperation({ 29 | query: 'query Query($address: String!, $collection: String!) { hasApproved(address: $address, collection: $collection) }', 30 | variables: { address: '0x54BE3a794282C030b15E43aE2bB182E14c409C5e', collection: '0x34d85c9CDeB23FA97cb08333b511ac86E1C4E258' } 31 | }); 32 | 33 | expect(result.data.hasApproved).toBe(false); 34 | }); 35 | 36 | it("should check an approved collection with ens", async function () { 37 | jest.setTimeout(10_000); // set timeout to be longer as this can take longer 38 | const result = await server.executeOperation({ 39 | query: 'query Query($address: String!, $collection: String!) { hasApproved(address: $address, collection: $collection) }', 40 | variables: { address: 'dingaling.eth', collection: '0x23581767a106ae21c074b2276d25e5c3e136a68b' } 41 | }); 42 | 43 | expect(result.data.hasApproved).toBe(true); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/node 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=node 4 | 5 | ### Node ### 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | .pnpm-debug.log* 14 | 15 | # Diagnostic reports (https://nodejs.org/api/report.html) 16 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 17 | 18 | # Runtime data 19 | pids 20 | *.pid 21 | *.seed 22 | *.pid.lock 23 | 24 | # Directory for instrumented libs generated by jscoverage/JSCover 25 | lib-cov 26 | 27 | # Coverage directory used by tools like istanbul 28 | coverage 29 | *.lcov 30 | 31 | # nyc test coverage 32 | .nyc_output 33 | 34 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 35 | .grunt 36 | 37 | # Bower dependency directory (https://bower.io/) 38 | bower_components 39 | 40 | # node-waf configuration 41 | .lock-wscript 42 | 43 | # Compiled binary addons (https://nodejs.org/api/addons.html) 44 | build/Release 45 | 46 | # Dependency directories 47 | node_modules/ 48 | jspm_packages/ 49 | 50 | # Snowpack dependency directory (https://snowpack.dev/) 51 | web_modules/ 52 | 53 | # TypeScript cache 54 | *.tsbuildinfo 55 | 56 | # Optional npm cache directory 57 | .npm 58 | 59 | # Optional eslint cache 60 | .eslintcache 61 | 62 | # Optional stylelint cache 63 | .stylelintcache 64 | 65 | # Microbundle cache 66 | .rpt2_cache/ 67 | .rts2_cache_cjs/ 68 | .rts2_cache_es/ 69 | .rts2_cache_umd/ 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | 74 | # Output of 'npm pack' 75 | *.tgz 76 | 77 | # Yarn Integrity file 78 | .yarn-integrity 79 | 80 | # dotenv environment variable files 81 | .env 82 | .env.development.local 83 | .env.test.local 84 | .env.production.local 85 | .env.local 86 | 87 | # parcel-bundler cache (https://parceljs.org/) 88 | .cache 89 | .parcel-cache 90 | 91 | # Next.js build output 92 | .next 93 | out 94 | 95 | # Nuxt.js build / generate output 96 | .nuxt 97 | dist 98 | 99 | # Gatsby files 100 | .cache/ 101 | # Comment in the public line in if your project uses Gatsby and not Next.js 102 | # https://nextjs.org/blog/next-9-1#public-directory-support 103 | # public 104 | 105 | # vuepress build output 106 | .vuepress/dist 107 | 108 | # vuepress v2.x temp and cache directory 109 | .temp 110 | 111 | # Docusaurus cache and generated files 112 | .docusaurus 113 | 114 | # Serverless directories 115 | .serverless/ 116 | 117 | # FuseBox cache 118 | .fusebox/ 119 | 120 | # DynamoDB Local files 121 | .dynamodb/ 122 | 123 | # TernJS port file 124 | .tern-port 125 | 126 | # Stores VSCode versions used for testing VSCode extensions 127 | .vscode-test 128 | 129 | # yarn v2 130 | .yarn/cache 131 | .yarn/unplugged 132 | .yarn/build-state.yml 133 | .yarn/install-state.gz 134 | .pnp.* 135 | 136 | ### Node Patch ### 137 | # Serverless Webpack directories 138 | .webpack/ 139 | 140 | # Optional stylelint cache 141 | 142 | # SvelteKit build / generate output 143 | .svelte-kit 144 | 145 | # End of https://www.toptal.com/developers/gitignore/api/node -------------------------------------------------------------------------------- /nexus-typegen.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was generated by Nexus Schema 3 | * Do not make changes to this file directly 4 | */ 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | declare global { 13 | interface NexusGen extends NexusGenTypes {} 14 | } 15 | 16 | export interface NexusGenInputs { 17 | } 18 | 19 | export interface NexusGenEnums { 20 | } 21 | 22 | export interface NexusGenScalars { 23 | String: string 24 | Int: number 25 | Float: number 26 | Boolean: boolean 27 | ID: string 28 | } 29 | 30 | export interface NexusGenObjects { 31 | Query: {}; 32 | } 33 | 34 | export interface NexusGenInterfaces { 35 | } 36 | 37 | export interface NexusGenUnions { 38 | } 39 | 40 | export type NexusGenRootTypes = NexusGenObjects 41 | 42 | export type NexusGenAllTypes = NexusGenRootTypes & NexusGenScalars 43 | 44 | export interface NexusGenFieldTypes { 45 | Query: { // field return type 46 | hasApproved: boolean | null; // Boolean 47 | } 48 | } 49 | 50 | export interface NexusGenFieldTypeNames { 51 | Query: { // field return type name 52 | hasApproved: 'Boolean' 53 | } 54 | } 55 | 56 | export interface NexusGenArgTypes { 57 | Query: { 58 | hasApproved: { // args 59 | address: string; // String! 60 | collection: string; // String! 61 | } 62 | } 63 | } 64 | 65 | export interface NexusGenAbstractTypeMembers { 66 | } 67 | 68 | export interface NexusGenTypeInterfaces { 69 | } 70 | 71 | export type NexusGenObjectNames = keyof NexusGenObjects; 72 | 73 | export type NexusGenInputNames = never; 74 | 75 | export type NexusGenEnumNames = never; 76 | 77 | export type NexusGenInterfaceNames = never; 78 | 79 | export type NexusGenScalarNames = keyof NexusGenScalars; 80 | 81 | export type NexusGenUnionNames = never; 82 | 83 | export type NexusGenObjectsUsingAbstractStrategyIsTypeOf = never; 84 | 85 | export type NexusGenAbstractsUsingStrategyResolveType = never; 86 | 87 | export type NexusGenFeaturesConfig = { 88 | abstractTypeStrategies: { 89 | isTypeOf: false 90 | resolveType: true 91 | __typename: false 92 | } 93 | } 94 | 95 | export interface NexusGenTypes { 96 | context: any; 97 | inputTypes: NexusGenInputs; 98 | rootTypes: NexusGenRootTypes; 99 | inputTypeShapes: NexusGenInputs & NexusGenEnums & NexusGenScalars; 100 | argTypes: NexusGenArgTypes; 101 | fieldTypes: NexusGenFieldTypes; 102 | fieldTypeNames: NexusGenFieldTypeNames; 103 | allTypes: NexusGenAllTypes; 104 | typeInterfaces: NexusGenTypeInterfaces; 105 | objectNames: NexusGenObjectNames; 106 | inputNames: NexusGenInputNames; 107 | enumNames: NexusGenEnumNames; 108 | interfaceNames: NexusGenInterfaceNames; 109 | scalarNames: NexusGenScalarNames; 110 | unionNames: NexusGenUnionNames; 111 | allInputTypes: NexusGenTypes['inputNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['scalarNames']; 112 | allOutputTypes: NexusGenTypes['objectNames'] | NexusGenTypes['enumNames'] | NexusGenTypes['unionNames'] | NexusGenTypes['interfaceNames'] | NexusGenTypes['scalarNames']; 113 | allNamedTypes: NexusGenTypes['allInputTypes'] | NexusGenTypes['allOutputTypes'] 114 | abstractTypes: NexusGenTypes['interfaceNames'] | NexusGenTypes['unionNames']; 115 | abstractTypeMembers: NexusGenAbstractTypeMembers; 116 | objectsUsingAbstractStrategyIsTypeOf: NexusGenObjectsUsingAbstractStrategyIsTypeOf; 117 | abstractsUsingStrategyResolveType: NexusGenAbstractsUsingStrategyResolveType; 118 | features: NexusGenFeaturesConfig; 119 | } 120 | 121 | 122 | declare global { 123 | interface NexusGenPluginTypeConfig { 124 | } 125 | interface NexusGenPluginInputTypeConfig { 126 | } 127 | interface NexusGenPluginFieldConfig { 128 | } 129 | interface NexusGenPluginInputFieldConfig { 130 | } 131 | interface NexusGenPluginSchemaConfig { 132 | } 133 | interface NexusGenPluginArgConfig { 134 | } 135 | } -------------------------------------------------------------------------------- /src/graphql/index.ts: -------------------------------------------------------------------------------- 1 | import { Contract } from 'ethers-multicall'; 2 | import { nonNull, objectType, stringArg } from 'nexus'; 3 | import { multiCallProvider, provider } from '../app'; 4 | import { erc721abi, ERC721_ID } from '../constants'; 5 | 6 | const hasApprovedArgs = { 7 | address: nonNull( 8 | stringArg({ 9 | description: 'ENS / EOA address', 10 | }), 11 | ), 12 | collection: nonNull( 13 | stringArg({ 14 | description: 'ERC721 address', 15 | }), 16 | ), 17 | }; 18 | 19 | type AddressData = { 20 | isEns: boolean; 21 | value: string; 22 | }; 23 | 24 | const sanitizeAndValidateAddress = (address: string): AddressData => { 25 | const regex = new RegExp(/^0x[a-fA-F0-9]{40}$/); 26 | let sanitized = address.replace(/[^a-z0-9áéíóúñü .,_-]/gim, '').trim(); 27 | let isEns = false; 28 | if (sanitized.toLowerCase().endsWith('.eth')) { 29 | // we can check vs lowercase as ENS records are case insensitive 30 | isEns = true; 31 | } else { 32 | if (!sanitized.startsWith('0x')) { 33 | sanitized = '0x'.concat(sanitized); 34 | } 35 | 36 | if (!regex.test(sanitized)) { 37 | throw new Error( 38 | 'Provided address was EOA but failed to match RegEx', 39 | ); 40 | } 41 | } 42 | 43 | return { isEns, value: sanitized }; 44 | }; 45 | 46 | const getAddressFromEns = async (address: string): Promise => { 47 | const resolver = await provider.getResolver(address); 48 | if (!resolver) { 49 | throw new Error(`${address} is not a registered ENS domain`); 50 | } 51 | const resolved = await resolver.getAddress(); 52 | return resolved; 53 | }; 54 | 55 | export const hasApproved = objectType({ 56 | name: 'Query', 57 | definition(t) { 58 | t.field('hasApproved', { 59 | type: 'Boolean', 60 | args: hasApprovedArgs, 61 | resolve: async (_, { address, collection }) => { 62 | const { isEns: addressEns, value: realAddress } = 63 | sanitizeAndValidateAddress(address); 64 | const { isEns: collectionEns, value: collectionAddress } = 65 | sanitizeAndValidateAddress(collection); 66 | const addressToCheck = addressEns 67 | ? await getAddressFromEns(realAddress) 68 | : realAddress; 69 | const collectionToCheck = collectionEns 70 | ? await getAddressFromEns(collectionAddress) 71 | : collectionAddress; 72 | 73 | const collectionContract = new Contract( 74 | collectionToCheck, 75 | erc721abi, 76 | ); 77 | const supporstsInterfacePromise = 78 | collectionContract.supportsInterface(ERC721_ID); 79 | const hasApprovedPromise = collectionContract.isApprovedForAll( 80 | addressToCheck, 81 | '0xf42aa99F011A1fA7CDA90E5E98b277E306BcA83e', // LooksRare TransferManagerERC721 address on mainnet 82 | ); 83 | 84 | try { 85 | // supportsInterface will revert if the contract does not support the function, so 86 | // we deal with that error in the catch clause. 87 | const [isErc721, hasApproved] = await multiCallProvider.all( 88 | [supporstsInterfacePromise, hasApprovedPromise], 89 | ); 90 | if (!isErc721) { 91 | throw new Error( 92 | 'Tried to check approval against a non-ERC721 collection', 93 | ); 94 | } 95 | 96 | return hasApproved; 97 | } catch (err) { 98 | throw new Error("Check failed, most likely this means you did not provide an ERC721 compatible address!"); 99 | } 100 | }, 101 | }); 102 | }, 103 | }); 104 | -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * For a detailed explanation regarding each configuration property and type check, visit: 3 | * https://jestjs.io/docs/configuration 4 | */ 5 | 6 | export default { 7 | // All imported modules in your tests should be mocked automatically 8 | // automock: false, 9 | 10 | // Stop running tests after `n` failures 11 | // bail: 0, 12 | 13 | // The directory where Jest should store its cached dependency information 14 | // cacheDirectory: "/private/var/folders/yl/89z7y0ds2vn76134s_1qstmc0000gn/T/jest_dx", 15 | 16 | // Automatically clear mock calls, instances, contexts and results before every test 17 | // clearMocks: false, 18 | 19 | // Indicates whether the coverage information should be collected while executing the test 20 | collectCoverage: false, 21 | 22 | // An array of glob patterns indicating a set of files for which coverage information should be collected 23 | // collectCoverageFrom: undefined, 24 | 25 | // The directory where Jest should output its coverage files 26 | coverageDirectory: "coverage", 27 | 28 | // An array of regexp pattern strings used to skip coverage collection 29 | // coveragePathIgnorePatterns: [ 30 | // "/node_modules/" 31 | // ], 32 | 33 | // Indicates which provider should be used to instrument code for coverage 34 | coverageProvider: "v8", 35 | 36 | // A list of reporter names that Jest uses when writing coverage reports 37 | // coverageReporters: [ 38 | // "json", 39 | // "text", 40 | // "lcov", 41 | // "clover" 42 | // ], 43 | 44 | // An object that configures minimum threshold enforcement for coverage results 45 | // coverageThreshold: undefined, 46 | 47 | // A path to a custom dependency extractor 48 | // dependencyExtractor: undefined, 49 | 50 | // Make calling deprecated APIs throw helpful error messages 51 | // errorOnDeprecated: false, 52 | 53 | // The default configuration for fake timers 54 | // fakeTimers: { 55 | // "enableGlobally": false 56 | // }, 57 | 58 | // Force coverage collection from ignored files using an array of glob patterns 59 | // forceCoverageMatch: [], 60 | 61 | // A path to a module which exports an async function that is triggered once before all test suites 62 | // globalSetup: undefined, 63 | 64 | // A path to a module which exports an async function that is triggered once after all test suites 65 | // globalTeardown: undefined, 66 | 67 | // A set of global variables that need to be available in all test environments 68 | // globals: {}, 69 | 70 | // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. 71 | // maxWorkers: "50%", 72 | 73 | // An array of directory names to be searched recursively up from the requiring module's location 74 | // moduleDirectories: [ 75 | // "node_modules" 76 | // ], 77 | 78 | // An array of file extensions your modules use 79 | // moduleFileExtensions: [ 80 | // "js", 81 | // "mjs", 82 | // "cjs", 83 | // "jsx", 84 | // "ts", 85 | // "tsx", 86 | // "json", 87 | // "node" 88 | // ], 89 | 90 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module 91 | // moduleNameMapper: {}, 92 | 93 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader 94 | // modulePathIgnorePatterns: [], 95 | 96 | // Activates notifications for test results 97 | // notify: false, 98 | 99 | // An enum that specifies notification mode. Requires { notify: true } 100 | // notifyMode: "failure-change", 101 | 102 | // A preset that is used as a base for Jest's configuration 103 | preset: 'ts-jest', 104 | 105 | // Run tests from one or more projects 106 | // projects: undefined, 107 | 108 | // Use this configuration option to add custom reporters to Jest 109 | // reporters: undefined, 110 | 111 | // Automatically reset mock state before every test 112 | // resetMocks: false, 113 | 114 | // Reset the module registry before running each individual test 115 | // resetModules: false, 116 | 117 | // A path to a custom resolver 118 | // resolver: undefined, 119 | 120 | // Automatically restore mock state and implementation before every test 121 | // restoreMocks: false, 122 | 123 | // The root directory that Jest should scan for tests and modules within 124 | // rootDir: undefined, 125 | 126 | // A list of paths to directories that Jest should use to search for files in 127 | // roots: [ 128 | // "" 129 | // ], 130 | 131 | // Allows you to use a custom runner instead of Jest's default test runner 132 | // runner: "jest-runner", 133 | 134 | // The paths to modules that run some code to configure or set up the testing environment before each test 135 | // setupFiles: [], 136 | 137 | // A list of paths to modules that run some code to configure or set up the testing framework before each test 138 | // setupFilesAfterEnv: [], 139 | 140 | // The number of seconds after which a test is considered as slow and reported as such in the results. 141 | // slowTestThreshold: 5, 142 | 143 | // A list of paths to snapshot serializer modules Jest should use for snapshot testing 144 | // snapshotSerializers: [], 145 | 146 | // The test environment that will be used for testing 147 | testEnvironment: "node", 148 | 149 | // Options that will be passed to the testEnvironment 150 | // testEnvironmentOptions: {}, 151 | 152 | // Adds a location field to test results 153 | // testLocationInResults: false, 154 | 155 | // The glob patterns Jest uses to detect test files 156 | // testMatch: [ 157 | // "**/__tests__/**/*.[jt]s?(x)", 158 | // "**/?(*.)+(spec|test).[tj]s?(x)" 159 | // ], 160 | 161 | // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped 162 | // testPathIgnorePatterns: [ 163 | // "/node_modules/" 164 | // ], 165 | 166 | // The regexp pattern or array of patterns that Jest uses to detect test files 167 | // testRegex: [], 168 | 169 | // This option allows the use of a custom results processor 170 | // testResultsProcessor: undefined, 171 | 172 | // This option allows use of a custom test runner 173 | // testRunner: "jest-circus/runner", 174 | 175 | // A map from regular expressions to paths to transformers 176 | // transform: undefined, 177 | 178 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation 179 | // transformIgnorePatterns: [ 180 | // "/node_modules/", 181 | // "\\.pnp\\.[^\\/]+$" 182 | // ], 183 | 184 | // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them 185 | // unmockedModulePathPatterns: undefined, 186 | 187 | // Indicates whether each individual test should be reported during the run 188 | // verbose: undefined, 189 | 190 | // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode 191 | // watchPathIgnorePatterns: [], 192 | 193 | // Whether to use watchman for file crawling 194 | // watchman: true, 195 | }; 196 | --------------------------------------------------------------------------------