chore: perauset customer project
This commit is contained in:
24
packages/functions/tests/package.json
Normal file
24
packages/functions/tests/package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "tests",
|
||||
"version": "0.0.1",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "Function test harness — Cucumber over in-process Pikku RPC with stubbed services.",
|
||||
"scripts": {
|
||||
"test": "node --env-file=.env.test node_modules/.bin/cucumber-js --config tests/cucumber.mjs --tags 'not @skip'",
|
||||
"test:tag": "node --env-file=.env.test node_modules/.bin/cucumber-js --config tests/cucumber.mjs --tags",
|
||||
"coverage": "pikku tests coverage",
|
||||
"tsc": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pikku/cucumber": "0.12.9",
|
||||
"@pikku/kysely-node-sqlite": "^0.12.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cucumber/cucumber": "^11.0.0",
|
||||
"@types/node": "^22",
|
||||
"c8": "^10.0.0",
|
||||
"tsx": "^4.21.0",
|
||||
"typescript": "~5.8.0"
|
||||
}
|
||||
}
|
||||
7
packages/functions/tests/tests/cucumber.mjs
Normal file
7
packages/functions/tests/tests/cucumber.mjs
Normal file
@@ -0,0 +1,7 @@
|
||||
export default {
|
||||
requireModule: ['tsx'],
|
||||
require: ['tests/support/**/*.ts', 'tests/steps/**/*.ts'],
|
||||
paths: ['tests/features/**/*.feature'],
|
||||
format: ['progress', 'html:tests/reports/cucumber-report.html'],
|
||||
forceExit: true,
|
||||
}
|
||||
0
packages/functions/tests/tests/features/.gitkeep
Normal file
0
packages/functions/tests/tests/features/.gitkeep
Normal file
7
packages/functions/tests/tests/support/hooks.ts
Normal file
7
packages/functions/tests/tests/support/hooks.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import '../../../.pikku/pikku-bootstrap.gen.js'
|
||||
import { Before, After, BeforeAll, AfterAll, setDefaultTimeout, Given, When, Then } from '@cucumber/cucumber'
|
||||
import { registerHooks, registerCommonSteps } from '@pikku/cucumber'
|
||||
import { db } from './services.js'
|
||||
|
||||
registerHooks({ Before, After, BeforeAll, AfterAll, setDefaultTimeout }, db)
|
||||
registerCommonSteps({ Given, When, Then })
|
||||
14
packages/functions/tests/tests/support/services.ts
Normal file
14
packages/functions/tests/tests/support/services.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { createDbUtils, type StubTracker } from '@pikku/cucumber'
|
||||
import { createConfig } from '../../../src/config.js'
|
||||
import { createSingletonServices } from '../../../src/services.js'
|
||||
|
||||
export const db = createDbUtils({ migrationsDir: '', seedFile: '' })
|
||||
|
||||
export async function createStubServices(_dbFile: string, tracker: StubTracker) {
|
||||
const injected = new Proxy({} as Record<string, unknown>, {
|
||||
get(_, prop: string) { return tracker.stub(prop) },
|
||||
})
|
||||
const config = await createConfig()
|
||||
const services = await createSingletonServices(config as never, injected as never)
|
||||
return { services }
|
||||
}
|
||||
5
packages/functions/tests/tests/support/world.ts
Normal file
5
packages/functions/tests/tests/support/world.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { World, setWorldConstructor } from '@cucumber/cucumber'
|
||||
import { createFunctionWorld } from '@pikku/cucumber'
|
||||
import { createStubServices } from './services.js'
|
||||
|
||||
createFunctionWorld(World, setWorldConstructor, createStubServices)
|
||||
18
packages/functions/tests/tsconfig.json
Normal file
18
packages/functions/tests/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"types": [
|
||||
"node"
|
||||
],
|
||||
"noEmit": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true,
|
||||
"strict": true
|
||||
},
|
||||
"include": [
|
||||
"tests/**/*.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user