From 6e4cdf050303175154586d307f27a8edb281c558 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 6 Mar 2024 17:36:34 -0800 Subject: [PATCH] chore: migrate from TestFile to test suite --- src/extension.ts | 29 ++++-- src/playwrightTest.ts | 4 +- src/reusedBrowser.ts | 2 +- src/testModel.ts | 197 ++++++++++++++--------------------- src/testTree.ts | 50 ++------- src/upstream/teleReceiver.ts | 8 +- src/watchSupport.ts | 2 +- tests/list-files.spec.ts | 1 + tests/list-tests.spec.ts | 14 +-- tests/mock/vscode.ts | 12 +-- tests/source-map.spec.ts | 3 +- tests/watch.spec.ts | 12 +-- 12 files changed, 137 insertions(+), 197 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index a5c2395b5..3a9e7be2e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -24,7 +24,7 @@ import * as reporterTypes from './reporter'; import { ReusedBrowser } from './reusedBrowser'; import { SettingsModel } from './settingsModel'; import { SettingsView } from './settingsView'; -import { TestModel, TestProject } from './testModel'; +import { TestModel, TestProject, projectFiles } from './testModel'; import { TestTree } from './testTree'; import { NodeJSNotFoundError, ansiToHtml } from './utils'; import * as vscodeTypes from './vscodeTypes'; @@ -310,7 +310,7 @@ export class Extension implements RunHooks { for (const model of this._models) { for (const project of model.allProjects().values()) { this._createRunProfile(project, existingProfiles); - this._workspaceObserver.addWatchFolder(project.testDir); + this._workspaceObserver.addWatchFolder(project.project.testDir); } } for (const [id, profile] of existingProfiles) { @@ -369,19 +369,31 @@ export class Extension implements RunHooks { const projectPrefix = project.name ? `${project.name} — ` : ''; const keyPrefix = configFile + ':' + project.name; let runProfile = existingProfiles.get(keyPrefix + ':run'); - const projectTag = this._testTree.projectTag(project); const isDefault = false; const supportsContinuousRun = this._settingsModel.allowWatchingFiles.get(); if (!runProfile) - runProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Run, this._scheduleTestRunRequest.bind(this, configFile, project.name, false), isDefault, projectTag, supportsContinuousRun); + runProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Run, this._scheduleTestRunRequest.bind(this, configFile, project.name, false), isDefault, undefined, supportsContinuousRun); this._runProfiles.set(keyPrefix + ':run', runProfile); let debugProfile = existingProfiles.get(keyPrefix + ':debug'); if (!debugProfile) - debugProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Debug, this._scheduleTestRunRequest.bind(this, configFile, project.name, true), isDefault, projectTag, supportsContinuousRun); + debugProfile = this._testController.createRunProfile(`${projectPrefix}${folderName}${path.sep}${configName}`, this._vscode.TestRunProfileKind.Debug, this._scheduleTestRunRequest.bind(this, configFile, project.name, true), isDefault, undefined, supportsContinuousRun); this._runProfiles.set(keyPrefix + ':debug', debugProfile); - runProfile.onDidChangeDefault(enabled => project.model.setProjectEnabled(project, enabled)); - debugProfile.onDidChangeDefault(enabled => project.model.setProjectEnabled(project, enabled)); + // Run profile has the current isEnabled value as per vscode. + project.isEnabled = runProfile.isDefault; + + runProfile.onDidChangeDefault(enabled => { + if (project.isEnabled === enabled) + return; + project.model.setProjectEnabled(project, enabled); + this._updateVisibleEditorItems(); + }); + debugProfile.onDidChangeDefault(enabled => { + if (project.isEnabled === enabled) + return; + project.model.setProjectEnabled(project, enabled); + this._updateVisibleEditorItems(); + }); } private _scheduleTestRunRequest(configFile: string, projectName: string, isDebug: boolean, request: vscodeTypes.TestRunRequest, cancellationToken?: vscodeTypes.CancellationToken) { @@ -526,7 +538,8 @@ located next to Run / Debug Tests toolbar buttons.`); for (const item of items) { const itemFsPath = item.uri!.fsPath; const projectsWithFile = projects.filter(project => { - for (const file of project.files.keys()) { + const files = projectFiles(project); + for (const file of files.keys()) { if (file.startsWith(itemFsPath)) return true; } diff --git a/src/playwrightTest.ts b/src/playwrightTest.ts index 0e7b8e8e2..8a164591b 100644 --- a/src/playwrightTest.ts +++ b/src/playwrightTest.ts @@ -194,7 +194,7 @@ export class PlaywrightTest { return; const configFolder = path.dirname(config.configFile); const configFile = path.basename(config.configFile); - const escapedLocations = locations.map(escapeRegex); + const escapedLocations = locations.map(escapeRegex).sort(); const args = []; if (mode === 'list') args.push('--list', '--reporter=null'); @@ -206,7 +206,7 @@ export class PlaywrightTest { { // For tests. - const relativeLocations = locations.map(f => path.relative(configFolder, f)).map(escapeRegex); + const relativeLocations = escapedLocations.map(f => path.relative(configFolder, f)); this._log(`${escapeRegex(path.relative(config.workspaceFolder, configFolder))}> playwright test -c ${configFile}${args.length ? ' ' + args.join(' ') : ''}${relativeLocations.length ? ' ' + relativeLocations.join(' ') : ''}`); } const allArgs = [config.cli, 'test', diff --git a/src/reusedBrowser.ts b/src/reusedBrowser.ts index c272d73eb..ff70c8b3d 100644 --- a/src/reusedBrowser.ts +++ b/src/reusedBrowser.ts @@ -329,7 +329,7 @@ export class ReusedBrowser implements vscodeTypes.Disposable { return; let file; for (let i = 1; i < 100; ++i) { - file = path.join(project.testDir, `test-${i}.spec.ts`); + file = path.join(project.project.testDir, `test-${i}.spec.ts`); if (fs.existsSync(file)) continue; break; diff --git a/src/testModel.ts b/src/testModel.ts index adf822c42..6909bbb0e 100644 --- a/src/testModel.ts +++ b/src/testModel.ts @@ -20,49 +20,15 @@ import * as vscodeTypes from './vscodeTypes'; import { resolveSourceMap } from './utils'; import { ProjectConfigWithFiles } from './listTests'; import * as reporterTypes from './reporter'; +import { TeleSuite } from './upstream/teleReceiver'; export type TestEntry = reporterTypes.TestCase | reporterTypes.Suite; -/** - * This class builds the Playwright Test model in Playwright terms. - * - TestModel maps to the Playwright config - * - TestProject maps to the Playwright project - * - TestFiles belong to projects and contain test entries. - * - * A single test in the source code, and a single test in VS Code UI can correspond to multiple entries - * in different configs / projects. TestTree will perform model -> UI mapping and will represent - * them as a single entity. - */ -export class TestFile { - readonly project: TestProject; - readonly file: string; - private _entries: TestEntry[] | undefined; - private _revision = 0; - - constructor(project: TestProject, file: string) { - this.project = project; - this.file = file; - } - - entries(): TestEntry[] | undefined { - return this._entries; - } - - setEntries(entries: TestEntry[]) { - ++this._revision; - this._entries = entries; - } - - revision(): number { - return this._revision; - } -} - export type TestProject = { - name: string; - testDir: string; model: TestModel; - files: Map; + name: string; + suite: reporterTypes.Suite; + project: reporterTypes.FullProject; isEnabled: boolean; }; @@ -102,7 +68,8 @@ export class TestModel { enabledFiles(): string[] { const result: string[] = []; for (const project of this.enabledProjects()) { - for (const file of project.files.keys()) + const files = projectFiles(project); + for (const file of files.keys()) result.push(file); } return result; @@ -140,11 +107,29 @@ export class TestModel { } private _createProject(projectReport: ProjectConfigWithFiles): TestProject { + const projectSuite = new TeleSuite(projectReport.name, 'project'); + projectSuite._project = { + dependencies: [], + grep: '.*', + grepInvert: null, + metadata: {}, + name: projectReport.name, + outputDir: '', + repeatEach: 0, + retries: 0, + snapshotDir: '', + testDir: projectReport.testDir, + testIgnore: [], + testMatch: '.*', + timeout: 0, + use: projectReport.use, + }; const project: TestProject = { model: this, - ...projectReport, - files: new Map(), - isEnabled: true, + name: projectReport.name, + suite: projectSuite, + project: projectSuite._project, + isEnabled: false, }; this._projects.set(project.name, project); return project; @@ -152,70 +137,35 @@ export class TestModel { private _updateProject(project: TestProject, projectReport: ProjectConfigWithFiles) { const filesToKeep = new Set(); + const files = projectFiles(project); for (const file of projectReport.files) { filesToKeep.add(file); - const testFile = project.files.get(file); - if (!testFile) - this._createFile(project, file); + const testFile = files.get(file); + if (!testFile) { + const testFile = new TeleSuite(file, 'file'); + testFile.location = { file, line: 0, column: 0 }; + files.set(file, testFile); + } } - for (const file of project.files.keys()) { + for (const file of files.keys()) { if (!filesToKeep.has(file)) - project.files.delete(file); + files.delete(file); } - } - - private _createFile(project: TestProject, file: string): TestFile { - const testFile = new TestFile(project, file); - project.files.set(file, testFile); - return testFile; + project.suite.suites = [...files.values()]; } async workspaceChanged(change: WorkspaceChange) { - let modelChanged = false; - // Translate source maps from files to sources. - change.changed = this._mapFilesToSources(change.changed); - change.created = this._mapFilesToSources(change.created); - change.deleted = this._mapFilesToSources(change.deleted); + const testDirs = [...new Set([...this._projects.values()].map(p => p.project.testDir))]; - if (change.deleted.size) { - for (const project of this._projects.values()) { - for (const file of change.deleted) { - if (project.files.has(file)) { - project.files.delete(file); - modelChanged = true; - } - } - } - } - - if (change.created.size) { - let hasMatchingFiles = false; - for (const project of this._projects.values()) { - for (const file of change.created) { - if (file.startsWith(project.testDir)) - hasMatchingFiles = true; - } - } - if (hasMatchingFiles) - await this.listFiles(); - } + const changed = this._mapFilesToSources(testDirs, change.changed); + const created = this._mapFilesToSources(testDirs, change.created); + const deleted = this._mapFilesToSources(testDirs, change.deleted); - if (change.changed.size) { - const filesToLoad = new Set(); - for (const project of this._projects.values()) { - for (const file of change.changed) { - const testFile = project.files.get(file); - if (!testFile || !testFile.entries()) - continue; - filesToLoad.add(file); - } - } - if (filesToLoad.size) - await this.listTests([...filesToLoad]); - } - if (modelChanged) - this._didUpdate.fire(); + if (created.length || deleted.length) + await this.listFiles(); + if (changed.length) + await this.listTests(changed); } async listTests(files: string[]): Promise { @@ -224,23 +174,23 @@ export class TestModel { return errors; } - private _updateProjects(projectSuites: reporterTypes.Suite[], requestedFiles: string[]) { + private _updateProjects(newProjectSuites: reporterTypes.Suite[], requestedFiles: string[]) { for (const [projectName, project] of this._projects) { - const projectSuite = projectSuites.find(e => e.project()!.name === projectName); - const filesToDelete = new Set(requestedFiles); - for (const fileSuite of projectSuite?.suites || []) { - filesToDelete.delete(fileSuite.location!.file); - const file = project.files.get(fileSuite.location!.file); - if (!file) - continue; - file.setEntries([...fileSuite.suites, ...fileSuite.tests]); + const files = projectFiles(project); + const newProjectSuite = newProjectSuites.find(e => e.project()!.name === projectName); + const filesToClear = new Set(requestedFiles); + for (const fileSuite of newProjectSuite?.suites || []) { + filesToClear.delete(fileSuite.location!.file); + files.set(fileSuite.location!.file, fileSuite); } - // We requested update for those, but got no entries. - for (const file of filesToDelete) { - const testFile = project.files.get(file); - if (testFile) - testFile.setEntries([]); + for (const file of filesToClear) { + const fileSuite = files.get(file); + if (fileSuite) { + fileSuite.suites = []; + fileSuite.tests = []; + } } + project.suite.suites = [...files.values()]; } this._didUpdate.fire(); } @@ -255,15 +205,15 @@ export class TestModel { private _updateFromRunningProject(project: TestProject, projectSuite: reporterTypes.Suite) { // When running tests, don't remove existing entries. + const files = projectFiles(project); for (const fileSuite of projectSuite.suites) { if (!fileSuite.allTests().length) continue; - let file = project.files.get(fileSuite.location!.file); - if (!file) - file = this._createFile(project, fileSuite.location!.file); - if (!file.entries()) - file.setEntries([...fileSuite.suites, ...fileSuite.tests]); + const existingFileSuite = files.get(fileSuite.location!.file); + if (!existingFileSuite || !existingFileSuite.allTests().length) + files.set(fileSuite.location!.file, fileSuite); } + project.suite.suites = [...files.values()]; this._didUpdate.fire(); } @@ -274,29 +224,40 @@ export class TestModel { async debugTests(projects: TestProject[], locations: string[] | null, reporter: reporterTypes.ReporterV2, parametrizedTestTitle: string | undefined, token: vscodeTypes.CancellationToken) { locations = locations || []; - await this._playwrightTest.debugTests(this._vscode, this.config, projects.map(p => p.name), projects.map(p => p.testDir), this._envProvider(), locations, reporter, parametrizedTestTitle, token); + const testDirs = projects.map(p => p.project.testDir); + await this._playwrightTest.debugTests(this._vscode, this.config, projects.map(p => p.name), testDirs, this._envProvider(), locations, reporter, parametrizedTestTitle, token); } - private _mapFilesToSources(files: Set): Set { + private _mapFilesToSources(testDirs: string[], files: Set): string[] { const result = new Set(); for (const file of files) { + if (!testDirs.some(t => file.startsWith(t + '/'))) + continue; const sources = this._fileToSources.get(file); if (sources) sources.forEach(f => result.add(f)); else result.add(file); } - return result; + return [...result]; } narrowDownFilesToEnabledProjects(fileNames: Set) { const result = new Set(); for (const project of this.enabledProjects()) { + const files = projectFiles(project); for (const fileName of fileNames) { - if (project.files.has(fileName)) + if (files.has(fileName)) result.add(fileName); } } return result; } } + +export function projectFiles(project: TestProject): Map { + const files = new Map(); + for (const fileSuite of project.suite.suites) + files.set(fileSuite.location!.file, fileSuite); + return files; +} diff --git a/src/testTree.ts b/src/testTree.ts index 55beaf3ce..56362b5af 100644 --- a/src/testTree.ts +++ b/src/testTree.ts @@ -16,12 +16,12 @@ import path from 'path'; import { MultiMap } from './multimap'; -import { TestModel, TestProject, TestEntry } from './testModel'; +import { TestModel, TestEntry } from './testModel'; import { createGuid } from './utils'; import * as vscodeTypes from './vscodeTypes'; import * as reporterTypes from './reporter'; -type EntriesByTitle = MultiMap; +type EntriesByTitle = MultiMap; type EntryType = 'test' | 'suite'; /** @@ -110,26 +110,18 @@ export class TestTree { if (!this._belongsToWorkspace(file)) continue; const fileItem = this.getOrCreateFileItem(file); - const signature: string[] = []; const entriesByTitle: EntriesByTitle = new MultiMap(); for (const model of this._models) { for (const testProject of model.enabledProjects()) { - const testFile = testProject.files.get(file); - if (!testFile || !testFile.entries()) + const fileSuites = testProject.suite.suites; + const fileSuite = fileSuites.find(s => s.location!.file === file); + if (!fileSuite || !fileSuite.allTests().length) continue; - const projectTag = this.projectTag(testProject); - this._tagFileItem(fileItem, projectTag); - signature.push(testProject.testDir + ':' + testProject.name + ':' + testFile.revision()); - for (const entry of testFile.entries() || []) - entriesByTitle.set(entry.title, { entry, projectTag }); + for (const entry of [...fileSuite.suites, ...fileSuite.tests]) + entriesByTitle.set(entry.title, entry); } } - - const signatureText = signature.join('|'); - if ((fileItem as any)[signatureSymbol] !== signatureText) { - (fileItem as any)[signatureSymbol] = signatureText; - this._updateTestItems(fileItem.children, entriesByTitle); - } + this._updateTestItems(fileItem.children, entriesByTitle); } for (const [location, fileItem] of this._fileItems) { @@ -171,7 +163,7 @@ export class TestTree { for (const [title, entriesWithTag] of entriesByTitle) { // Process each testItem exactly once. let testItem = existingItems.get(title); - const firstEntry = entriesWithTag[0].entry; + const firstEntry = entriesWithTag[0]; const entryLocation = firstEntry.location!; if (!testItem) { // We sort by id in tests, so start with location. @@ -185,14 +177,12 @@ export class TestTree { } const childEntries: EntriesByTitle = new MultiMap(); - for (const { projectTag, entry } of entriesWithTag) { - if (!testItem.tags.includes(projectTag)) - testItem.tags = [...testItem.tags, projectTag]; + for (const entry of entriesWithTag) { if ('id' in entry) { addTestIdToTreeItem(testItem, entry.id); } else { for (const child of [...entry.suites, ...entry.tests]) - childEntries.set(child.title, { entry: child, projectTag }); + childEntries.set(child.title, child); } } itemsToDelete.delete(testItem); @@ -251,13 +241,6 @@ export class TestTree { return result || fileItem; } - private _tagFileItem(fileItem: vscodeTypes.TestItem, projectTag: vscodeTypes.TestTag) { - for (let item: vscodeTypes.TestItem | undefined = fileItem; item; item = item.parent) { - if (!item.tags.includes(projectTag)) - item.tags = [...item.tags, projectTag]; - } - } - getOrCreateFileItem(file: string): vscodeTypes.TestItem { const result = this._fileItems.get(file); if (result) @@ -289,15 +272,6 @@ export class TestTree { private _id(location: string): string { return this._testGeneration + location; } - - projectTag(project: TestProject): vscodeTypes.TestTag { - let tag = (project as any)[tagSymbol]; - if (!tag) { - tag = new this._vscode.TestTag(project.model.config.configFile + ':' + project.name); - (project as any)[tagSymbol] = tag; - } - return tag; - } } function titleMatches(testItem: vscodeTypes.TestItem, titlePath: string[]) { @@ -322,7 +296,5 @@ function addTestIdToTreeItem(testItem: vscodeTypes.TestItem, testId: string) { (testItem as any)[testIdsSymbol] = testIds; } -const signatureSymbol = Symbol('signatureSymbol'); const itemTypeSymbol = Symbol('itemTypeSymbol'); const testIdsSymbol = Symbol('testIdsSymbol'); -const tagSymbol = Symbol('tagSymbol'); diff --git a/src/upstream/teleReceiver.ts b/src/upstream/teleReceiver.ts index 625a9a327..ae88861f7 100644 --- a/src/upstream/teleReceiver.ts +++ b/src/upstream/teleReceiver.ts @@ -126,6 +126,7 @@ type TeleReporterReceiverOptions = { mergeTestCases: boolean; resolvePath: (rootDir: string, relativePath: string) => string; configOverrides?: Pick; + clearPreviousResultsWhenTestBegins?: boolean; }; export class TeleReporterReceiver { @@ -135,7 +136,6 @@ export class TeleReporterReceiver { private _tests = new Map(); private _rootDir!: string; private _listOnly = false; - private _clearPreviousResultsWhenTestBegins: boolean = false; private _config!: reporterTypes.FullConfig; constructor(reporter: Partial, options: TeleReporterReceiverOptions) { @@ -189,10 +189,6 @@ export class TeleReporterReceiver { return this._onExit(); } - _setClearPreviousResultsWhenTestBegins() { - this._clearPreviousResultsWhenTestBegins = true; - } - private _onConfigure(config: JsonConfig) { this._rootDir = config.rootDir; this._config = this._parseConfig(config); @@ -234,7 +230,7 @@ export class TeleReporterReceiver { private _onTestBegin(testId: string, payload: JsonTestResultStart) { const test = this._tests.get(testId)!; - if (this._clearPreviousResultsWhenTestBegins) + if (this._options.clearPreviousResultsWhenTestBegins) test._clearResults(); const testResult = test._createTestResult(payload.id); testResult.retry = payload.retry; diff --git a/src/watchSupport.ts b/src/watchSupport.ts index a7b04c8b6..f4fc69935 100644 --- a/src/watchSupport.ts +++ b/src/watchSupport.ts @@ -34,7 +34,7 @@ export class WatchSupport { addToWatch(project: TestProject, include: readonly vscodeTypes.TestItem[] | undefined, cancellationToken: vscodeTypes.CancellationToken) { const watch: Watch = { - testDirFsPath: this.vscode.Uri.file(project.testDir).fsPath, + testDirFsPath: this.vscode.Uri.file(project.project.testDir).fsPath, project, include, }; diff --git a/tests/list-files.spec.ts b/tests/list-files.spec.ts index bed216225..0fed0ab13 100644 --- a/tests/list-files.spec.ts +++ b/tests/list-files.spec.ts @@ -205,6 +205,7 @@ test('should remove deleted files', async ({ activate }) => { expect(vscode).toHaveExecLog(` > playwright list-files -c playwright.config.js + > playwright list-files -c playwright.config.js `); }); diff --git a/tests/list-tests.spec.ts b/tests/list-tests.spec.ts index eed51972e..7f844c089 100644 --- a/tests/list-tests.spec.ts +++ b/tests/list-tests.spec.ts @@ -592,12 +592,12 @@ test('should merge items from different projects', async ({ activate }, testInfo await testController.expandTestItems(/test.spec.ts/); await testController.expandTestItems(/group/); - expect(testController.renderTestTree({ renderTags: true })).toBe(` - - test.spec.ts [desktop][mobile][tablet] - - group [2:0] [desktop][mobile] - - test 1 [3:0] [desktop] - - test 2 [@mobile] [4:0] [mobile] - - test 3 [@mobile] [5:0] [mobile] - - test 4 [6:0] [desktop] + expect(testController.renderTestTree()).toBe(` + - test.spec.ts + - group [2:0] + - test 1 [3:0] + - test 2 [@mobile] [4:0] + - test 3 [@mobile] [5:0] + - test 4 [6:0] `); }); diff --git a/tests/mock/vscode.ts b/tests/mock/vscode.ts index 7dee29a72..6b3bfd161 100644 --- a/tests/mock/vscode.ts +++ b/tests/mock/vscode.ts @@ -158,7 +158,6 @@ class TestItem { readonly map = new Map(); range: Range | undefined; parent: TestItem | undefined; - tags: TestTag[] = []; canResolveChildren = false; constructor( @@ -216,11 +215,10 @@ class TestItem { return result.join('\n'); } - innerToString(indent: string, result: string[], options?: { renderTags?: boolean }) { - const tags = options?.renderTags ? ' ' + this.tags.map(t => `[${t.name}]`).join('') : ''; - result.push(`${indent}- ${this.treeTitle()}${tags}`); + innerToString(indent: string, result: string[]) { + result.push(`${indent}- ${this.treeTitle()}`); for (const id of [...this.children.map.keys()].sort()) - this.children.map.get(id)!.innerToString(indent + ' ', result, options); + this.children.map.get(id)!.innerToString(indent + ' ', result); } treeTitle(): string { @@ -455,10 +453,10 @@ export class TestController { return testRun; } - renderTestTree(options?: { renderTags?: boolean }) { + renderTestTree() { const result: string[] = ['']; for (const item of this.items.map.values()) - item.innerToString(' ', result, options); + item.innerToString(' ', result); result.push(' '); return result.join('\n'); } diff --git a/tests/source-map.spec.ts b/tests/source-map.spec.ts index 5904bf4d7..3e99256c8 100644 --- a/tests/source-map.spec.ts +++ b/tests/source-map.spec.ts @@ -154,6 +154,7 @@ test('should remove deleted files', async ({ activate }) => { expect(vscode).toHaveExecLog(` > playwright list-files -c playwright.config.js + > playwright list-files -c playwright.config.js `); }); @@ -190,7 +191,7 @@ test('should discover new tests', async ({ activate }) => { expect(vscode).toHaveExecLog(` > playwright list-files -c playwright.config.js > playwright test -c playwright.config.js --list --reporter=null tests/test.spec.ts - > playwright test -c playwright.config.js --list --reporter=null tests/test.spec.ts + > playwright test -c playwright.config.js --list --reporter=null build/test.spec.js.map tests/test.spec.ts `); }); diff --git a/tests/watch.spec.ts b/tests/watch.spec.ts index 6e22beabd..2cc81cdee 100644 --- a/tests/watch.spec.ts +++ b/tests/watch.spec.ts @@ -48,6 +48,7 @@ test('should watch all tests', async ({ activate }) => { expect(testRun.renderLog()).toBe(` tests > test-1.spec.ts > should pass [2:0] + enqueued enqueued started passed @@ -55,6 +56,7 @@ test('should watch all tests', async ({ activate }) => { expect(vscode).toHaveExecLog(` > playwright list-files -c playwright.config.js + > playwright test -c playwright.config.js --list --reporter=null tests/test-1.spec.ts > playwright find-related-test-files -c playwright.config.js > playwright test -c playwright.config.js tests/test-1.spec.ts `); @@ -90,11 +92,12 @@ test('should unwatch all tests', async ({ activate }) => { expect(vscode).toHaveExecLog(` > playwright list-files -c playwright.config.js + > playwright test -c playwright.config.js --list --reporter=null tests/test-1.spec.ts `); }); test('should watch test file', async ({ activate }) => { - const { vscode, testController, workspaceFolder } = await activate({ + const { testController, workspaceFolder } = await activate({ 'playwright.config.js': `module.exports = { testDir: 'tests' }`, 'tests/test-1.spec.ts': ` import { test } from '@playwright/test'; @@ -125,16 +128,11 @@ test('should watch test file', async ({ activate }) => { expect(testRun.renderLog()).toBe(` tests > test-2.spec.ts > should pass [2:0] + enqueued enqueued started passed `); - - expect(vscode).toHaveExecLog(` - > playwright list-files -c playwright.config.js - > playwright find-related-test-files -c playwright.config.js - > playwright test -c playwright.config.js tests/test-2.spec.ts - `); }); test.skip('should watch tests via helper', async ({ activate }) => {