|
| 1 | +// * These tests run through the entire process of acquiring this software, |
| 2 | +// * using its features as described in the examples documentation, and dealing |
| 3 | +// * with its error conditions across a variety of runtimes (e.g. the currently |
| 4 | +// * maintained node versions). |
| 5 | +// * |
| 6 | +// * Typically, these tests involve the use of deep mock fixtures and/or Docker |
| 7 | +// * containers, and are built to run in GitHub Actions CI pipelines; some can |
| 8 | +// * also be run locally. |
| 9 | + |
| 10 | +import { toAbsolutePath, toDirname, toPath } from '@-xun/fs'; |
| 11 | +import { readXPackageJsonAtRoot } from '@-xun/project'; |
| 12 | +import { runnerFactory } from '@-xun/run'; |
| 13 | +import { createDebugLogger } from 'rejoinder'; |
| 14 | + |
| 15 | +import { exports as packageExports, name as packageName } from 'rootverse:package.json'; |
| 16 | + |
| 17 | +import { |
| 18 | + dummyFilesFixture, |
| 19 | + dummyNpmPackageFixture, |
| 20 | + ensurePackageHasBeenBuilt, |
| 21 | + mockFixturesFactory, |
| 22 | + npmCopyPackageFixture, |
| 23 | + reconfigureJestGlobalsToSkipTestsInThisFileIfRequested |
| 24 | +} from 'testverse:util.ts'; |
| 25 | + |
| 26 | +const shortIdentifier = packageName.split('/').at(-1)!; |
| 27 | +const TEST_IDENTIFIER = `${shortIdentifier}-e2e-examples`; |
| 28 | +const debug = createDebugLogger({ namespace: shortIdentifier }).extend(TEST_IDENTIFIER); |
| 29 | +const nodeVersion = process.env.XPIPE_MATRIX_NODE_VERSION || process.version; |
| 30 | + |
| 31 | +debug(`nodeVersion: "${nodeVersion}" (process.version=${process.version})`); |
| 32 | + |
| 33 | +reconfigureJestGlobalsToSkipTestsInThisFileIfRequested({ it: true, test: true }); |
| 34 | + |
| 35 | +beforeAll(async () => { |
| 36 | + await ensurePackageHasBeenBuilt( |
| 37 | + toDirname(toAbsolutePath(require.resolve('rootverse:package.json'))), |
| 38 | + packageName, |
| 39 | + packageExports |
| 40 | + ); |
| 41 | +}); |
| 42 | + |
| 43 | +const packageRoot = toPath(toAbsolutePath(__dirname), '../..'); |
| 44 | +const withMockedFixture = mockFixturesFactory( |
| 45 | + [dummyNpmPackageFixture, dummyFilesFixture, npmCopyPackageFixture], |
| 46 | + { |
| 47 | + performCleanup: true, |
| 48 | + initialVirtualFiles: { |
| 49 | + 'package.json': JSON.stringify( |
| 50 | + { |
| 51 | + name: 'dummy-pkg', |
| 52 | + version: '0.0.1', |
| 53 | + type: 'module' |
| 54 | + }, |
| 55 | + undefined, |
| 56 | + 2 |
| 57 | + ) |
| 58 | + }, |
| 59 | + packageUnderTest: { |
| 60 | + root: packageRoot, |
| 61 | + attributes: { cjs: true }, |
| 62 | + json: readXPackageJsonAtRoot.sync(packageRoot, { useCached: true }) |
| 63 | + }, |
| 64 | + identifier: TEST_IDENTIFIER |
| 65 | + } |
| 66 | +); |
| 67 | + |
| 68 | +describe('./examples', () => { |
| 69 | + test('example-todo', async () => { |
| 70 | + expect.hasAssertions(); |
| 71 | + }); |
| 72 | +}); |
0 commit comments