(args: FeaturesTestCommandInput, testResults: TestResult[] = [])
| 221 | } |
| 222 | |
| 223 | async function runFeatureTests(args: FeaturesTestCommandInput, testResults: TestResult[] = []): Promise<TestResult[]> { |
| 224 | const { baseImage, collectionFolder, remoteUser, cliHost, skipAutogenerated, skipScenarios, skipDuplicateTest } = args; |
| 225 | let { features } = args; |
| 226 | |
| 227 | const testsDir = `${collectionFolder}/test`; |
| 228 | |
| 229 | log(`baseImage: ${baseImage}`); |
| 230 | log(`Target Folder: ${collectionFolder}`); |
| 231 | |
| 232 | // Parse comma separated list of features |
| 233 | // If a set of '--features' isn't specified, run all features with a 'test' subfolder in random order. |
| 234 | if (!features) { |
| 235 | // Auto-detect |
| 236 | features = |
| 237 | (await cliHost.readDir(testsDir)) |
| 238 | .filter(f => f !== '_global'); // Exclude any folder named '_global' |
| 239 | |
| 240 | if (features.length === 0) { |
| 241 | fail(`No features specified and no test folders found in '${testsDir}'`); |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | log(`features: ${features.join(', ')}`); |
| 246 | |
| 247 | let workspaceFolder: string | undefined = undefined; |
| 248 | let params: DockerResolverParameters | undefined = undefined; |
| 249 | if (!skipAutogenerated) { |
| 250 | // Generate temporary project with 'baseImage' and all the 'features..' |
| 251 | workspaceFolder = await generateDefaultProjectFromFeatures( |
| 252 | cliHost, |
| 253 | baseImage, |
| 254 | collectionFolder, |
| 255 | features, |
| 256 | remoteUser |
| 257 | ); |
| 258 | |
| 259 | params = await generateDockerParams(workspaceFolder, args); |
| 260 | await createContainerFromWorkingDirectory(params, workspaceFolder, args); |
| 261 | } |
| 262 | |
| 263 | log('Starting test(s)...\n', { prefix: '\n🏃', info: true }); |
| 264 | |
| 265 | // Exec default 'test.sh' script for each feature, in the provided order. |
| 266 | // Also exec a test's test scenarios, if a scenarios.json is present in the feature's test folder. |
| 267 | for (const feature of features) { |
| 268 | log(`Starting '${feature}' tests...`, { prefix: '🧪' }); |
| 269 | const featureTestFolder = path.join(collectionFolder, 'test', feature); |
| 270 | |
| 271 | if (!skipAutogenerated) { |
| 272 | if (!workspaceFolder || !params) { |
| 273 | fail('Uninitialized workspaceFolder or params'); |
| 274 | return []; |
| 275 | } |
| 276 | await doRunAutoTest(feature, workspaceFolder, featureTestFolder, args, testResults); |
| 277 | } |
| 278 | |
| 279 | // If there is a feature-scoped 'scenarios.json' with additional tests, also exec those. |
| 280 | // Pass 'testResults' array reference in to capture results. |
no test coverage detected