(
testAssetName: string,
testFolderName: string,
suiteName: string,
env: NodeJS.ProcessEnv = {}
)
| 14 | export const integrationTestProjects = [basicSlnTestProject]; |
| 15 | |
| 16 | export async function runDevKitIntegrationTests( |
| 17 | testAssetName: string, |
| 18 | testFolderName: string, |
| 19 | suiteName: string, |
| 20 | env: NodeJS.ProcessEnv = {} |
| 21 | ) { |
| 22 | // Tests using C# Dev Kit tests are a bit different from the rest - we are not able to restart the Dev Kit server and there |
| 23 | // are not easy APIs to use to know if the project is reloading due to workspace changes. |
| 24 | // So we have to isolate the C# Dev Kit tests into smaller test runs (in this case, per file), where each run |
| 25 | // launches VSCode and runs the tests in that file. |
| 26 | const testFolder = path.join(rootPath, 'test', testFolderName); |
| 27 | console.log(`Searching for test files in ${testFolder}`); |
| 28 | const allFiles = fs |
| 29 | .readdirSync(testFolder, { |
| 30 | recursive: true, |
| 31 | }) |
| 32 | .filter((f) => typeof f === 'string'); |
| 33 | const devKitTestFiles = allFiles.filter((f) => f.endsWith('.test.ts')).map((f) => path.join(testFolder, f)); |
| 34 | if (devKitTestFiles.length === 0) { |
| 35 | throw new Error(`No test files found in ${testFolder}`); |
| 36 | } |
| 37 | |
| 38 | let failed: boolean = false; |
| 39 | for (const testFile of devKitTestFiles) { |
| 40 | try { |
| 41 | await runIntegrationTest( |
| 42 | testAssetName, |
| 43 | testFolderName, |
| 44 | suiteName, |
| 45 | `devkit_${testAssetName}.code-workspace`, |
| 46 | testFile, |
| 47 | env |
| 48 | ); |
| 49 | } catch (err) { |
| 50 | // We have to catch the error to continue running tests from the rest of the files. |
| 51 | console.error(`##[error] Tests in ${path.basename(testFile)} failed`, err); |
| 52 | failed = true; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | if (failed) { |
| 57 | // Ensure the task fails if any tests failed. |
| 58 | throw new Error(`One or more tests failed`); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | export async function runIntegrationTest( |
| 63 | testAssetName: string, |
no test coverage detected