()
| 120 | } |
| 121 | |
| 122 | function main(): number | void { |
| 123 | const jestCliBase = new JestCli(['--config', 'tests/functional/jest.config.js']) |
| 124 | let jestCli = jestCliBase |
| 125 | // Pass all the Jest params to Jest CLI |
| 126 | for (const cliArg of Object.keys(args)) { |
| 127 | // If it's a boolean, we only need to pass the flag |
| 128 | if (typeof jestArgs[cliArg] === 'function' && jestArgs[cliArg].name === 'Boolean') { |
| 129 | jestCli = jestCli.withArgs([cliArg]) |
| 130 | } else if (jestArgs[cliArg]) { |
| 131 | // eslint-disable-next-line @typescript-eslint/no-unsafe-argument |
| 132 | jestCli = jestCli.withArgs([cliArg, args[cliArg]]) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | if (args['--inspect-brk']) { |
| 137 | jestCli = jestCli.withDebugger() |
| 138 | } |
| 139 | |
| 140 | if (args['--preview-features']) { |
| 141 | jestCli = jestCli.withEnv({ TEST_PREVIEW_FEATURES: args['--preview-features'] }) |
| 142 | } |
| 143 | |
| 144 | if (args['--provider']) { |
| 145 | const providers = args['--provider'] as Providers[] |
| 146 | const unknownProviders = providers.filter((provider) => !allProviders.has(provider)) |
| 147 | if (unknownProviders.length > 0) { |
| 148 | throw new Error(`Unknown providers: ${unknownProviders.join(', ')}`) |
| 149 | } |
| 150 | jestCli = jestCli.withEnv({ ONLY_TEST_PROVIDERS: providers.join(',') }) |
| 151 | } |
| 152 | |
| 153 | if (args['--adapter']) { |
| 154 | const adapterProviders = args['--adapter'] as AdapterProviders[] |
| 155 | const unknownAdapterProviders = adapterProviders.filter( |
| 156 | (adapterProvider) => !allAdapterProviders.has(adapterProvider), |
| 157 | ) |
| 158 | |
| 159 | if (unknownAdapterProviders.length > 0) { |
| 160 | const allAdaptersStr = Array.from(allAdapterProviders) |
| 161 | .map((provider) => ` - ${provider}`) |
| 162 | .join('\n') |
| 163 | throw new Error( |
| 164 | `Unknown adapter providers: ${unknownAdapterProviders.join(', ')}. Available options:\n${allAdaptersStr}\n\n`, |
| 165 | ) |
| 166 | } |
| 167 | |
| 168 | if (adapterProviders.some(isDriverAdapterProviderLabel)) { |
| 169 | // Locally, running D1 tests accumulates a lot of data in the .wrangler directory. |
| 170 | // Because we cannot reset the database contents programmatically at the moment, |
| 171 | // deleting it is the easy way |
| 172 | // It makes local tests consistently fast and clean |
| 173 | fs.rmSync(path.join(__dirname, '..', '..', '.wrangler'), { recursive: true, force: true }) |
| 174 | |
| 175 | jestCli = jestCli.withArgs(['--runInBand']) |
| 176 | jestCli = jestCli.withEnv({ PRISMA_DISABLE_QUAINT_EXECUTORS: 'true' }) |
| 177 | jestCli = jestCli.withEnv({ TEST_REUSE_DATABASE: 'true' }) |
| 178 | } |
| 179 |
no test coverage detected