(opts: BuildOptions)
| 24 | ]; |
| 25 | |
| 26 | export async function buildTesting(opts: BuildOptions) { |
| 27 | const inputDir = path.join(opts.buildDir, 'testing'); |
| 28 | const sourceDir = path.join(opts.srcDir, 'testing'); |
| 29 | await fs.emptyDir(opts.output.testingDir); |
| 30 | |
| 31 | await Promise.all([ |
| 32 | // copy jest testing entry files |
| 33 | fs.copy(path.join(opts.scriptsBundlesDir, 'helpers', 'jest'), opts.output.testingDir), |
| 34 | copyTestingInternalDts(opts, inputDir), |
| 35 | ]); |
| 36 | |
| 37 | // write package.json |
| 38 | writePkgJson(opts, opts.output.testingDir, { |
| 39 | name: '@stencil/core/testing', |
| 40 | description: 'Stencil testing suite.', |
| 41 | main: 'index.js', |
| 42 | types: 'index.d.ts', |
| 43 | }); |
| 44 | |
| 45 | const external = [ |
| 46 | ...EXTERNAL_TESTING_MODULES, |
| 47 | ...externalNodeModules, |
| 48 | '../internal/testing/*', |
| 49 | '../cli/index.cjs', |
| 50 | '../sys/node/index.js', |
| 51 | '../compiler/stencil.js', |
| 52 | ]; |
| 53 | |
| 54 | const aliases = getEsbuildAliases(); |
| 55 | const testingEsbuildOptions: ESBuildOptions = { |
| 56 | ...getBaseEsbuildOptions(), |
| 57 | entryPoints: [path.join(sourceDir, 'index.ts')], |
| 58 | bundle: true, |
| 59 | format: 'cjs', |
| 60 | outfile: path.join(opts.output.testingDir, 'index.js'), |
| 61 | platform: 'node', |
| 62 | logLevel: 'info', |
| 63 | external, |
| 64 | /** |
| 65 | * set `write: false` so that we can run the `onEnd` hook |
| 66 | * in `lazyRequirePlugin` and modify the imports |
| 67 | */ |
| 68 | write: false, |
| 69 | alias: aliases, |
| 70 | banner: { js: getBanner(opts, `Stencil Testing`, true) }, |
| 71 | plugins: [ |
| 72 | externalAlias('@app-data', '@stencil/core/internal/app-data'), |
| 73 | externalAlias('@platform', '@stencil/core/internal/testing'), |
| 74 | externalAlias('../internal/testing/index.js', '@stencil/core/internal/testing'), |
| 75 | externalAlias('@stencil/core/dev-server', '../dev-server/index.js'), |
| 76 | externalAlias('@stencil/core/mock-doc', '../mock-doc/index.cjs'), |
| 77 | lazyRequirePlugin(opts, [ |
| 78 | '@stencil/core/internal/app-data', |
| 79 | '@stencil/core/internal/testing', |
| 80 | '../dev-server/index.js', |
| 81 | '../internal/testing/index.js', |
| 82 | '../mock-doc/index.cjs', |
| 83 | ]), |
no test coverage detected