Skip to content

Commit 46d7596

Browse files
committed
integration tests: testing infrastructure
Add the initial infrastructure for integration tests, following the pattern set with end-to-end tests in [1]. This includes Cucumber configuration and basic support classes. 1: bc8df92 Signed-off-by: Lessley Dennington <[email protected]>
1 parent d056872 commit 46d7596

File tree

4 files changed

+64
-2
lines changed

4 files changed

+64
-2
lines changed

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040

4141
// Cucumber settings
4242
"cucumber.features": [
43-
"test/e2e/features/**/*.feature",
43+
"test/**/features/**/*.feature",
4444
],
4545
"cucumber.glue": [
46-
"test/e2e/features/**/*.ts"
46+
"test/**/features/**/*.ts",
4747
],
4848
}

test/integration/cucumber.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const common = {
2+
requireModule: ['ts-node/register'],
3+
require: [`${__dirname}/features/**/*.ts`],
4+
publishQuiet: true,
5+
format: ['progress'],
6+
formatOptions: {
7+
snippetInterface: 'async-await'
8+
},
9+
worldParameters: {
10+
bundleServerCommand: `${__dirname}/../../bin/git-bundle-server`,
11+
trashDirectoryBase: `${__dirname}../../_test/integration`
12+
}
13+
}
14+
15+
module.exports = {
16+
default: {
17+
...common,
18+
},
19+
ci: {
20+
...common,
21+
tags: 'not @daemon',
22+
},
23+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as path from 'path'
2+
3+
export function absPath(pathParam: string): string {
4+
// Convert a given path (either relative to 'test/integration/' or absolute) to an
5+
// absolute path
6+
if (!path.isAbsolute(pathParam)) {
7+
return path.resolve(__dirname, "../..", pathParam)
8+
} else {
9+
return pathParam
10+
}
11+
}
12+
13+
export function repoRoot(pathParam: string): string {
14+
// Get repo root for given path
15+
if (!path.isAbsolute(pathParam)) {
16+
return path.resolve(__dirname, "../../../../git", pathParam)
17+
} else {
18+
return pathParam
19+
}
20+
}
21+
22+
export function routesPath(): string {
23+
// Get path to routes file
24+
return path.resolve(__dirname, "../../../../routes")
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { setWorldConstructor, World, IWorldOptions } from '@cucumber/cucumber'
2+
import * as child_process from 'child_process'
3+
4+
interface BundleServerParameters {
5+
bundleServerCommand: string
6+
}
7+
8+
export class BundleServerWorld extends World<BundleServerParameters> {
9+
runCommand(commandArgs: string): child_process.SpawnSyncReturns<Buffer> {
10+
return child_process.spawnSync(`${this.parameters.bundleServerCommand} ${commandArgs}`, [], { shell: true })
11+
}
12+
}
13+
14+
setWorldConstructor(BundleServerWorld)

0 commit comments

Comments
 (0)