Skip to content

Commit

Permalink
test: integration tests demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ruifigueira committed Jul 30, 2024
1 parent 38f2170 commit 9e829bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
21 changes: 18 additions & 3 deletions tests-integration/tests/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { test, expect } from './baseTest';

test('should be able to execute the first test of the example project', async ({ workbox }) => {
import { expect, test } from './baseTest';

test('should be able to execute the first test of the example project', async ({ activate, workbox }) => {
const { testController } = await activate({
'playwright.config.js': `module.exports = { testDir: 'tests' }`,
'tests/test.spec.ts': `
import { test } from '@playwright/test';
test('one', async () => {});
test('two', async () => {});
`,
});
await workbox.getByRole('treeitem', { name: 'tests', exact: true }).locator('a').click();
await workbox.getByRole('treeitem', { name: 'example.spec.ts' }).locator('a').click();
await workbox.getByRole('treeitem', { name: 'test.spec.ts' }).locator('a').click();
await expect(workbox.locator('.testing-run-glyph'), 'there are two tests in the file').toHaveCount(2);
await workbox.locator('.testing-run-glyph').first().click();
const passedLocator = workbox.locator('.monaco-editor').locator('.codicon-testing-passed-icon');
await expect(passedLocator).toHaveCount(1);
await expect(testController).toHaveTestTree(`
- tests
- test.spec.ts
- ✅ one [2:0]
- two [3:0]
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { enableConfigs, enableProjects, expect, test } from './utils';
import { expect, test, enableProjects, enableConfigs } from './baseTest';
import path from 'path';

test('should list files', async ({ activate }) => {
Expand Down Expand Up @@ -367,6 +367,8 @@ test('should list files in relative folder', async ({ activate }) => {
});

test('should list files in multi-folder workspace with project switching', async ({ activate }, testInfo) => {
test.fixme(true, 'multi-folder workspace not supported yet');

const { vscode, testController } = await activate({}, {
workspaceFolders: [
[testInfo.outputPath('folder1'), {
Expand Down Expand Up @@ -429,7 +431,7 @@ test('should ignore errors when listing files', async ({ activate }) => {
await expect.poll(() => vscode.languages.getDiagnostics()).toEqual([
{
message: 'Error: oh my',
range: { start: { line: 0, character: 6 }, end: { line: 1, character: 0 } },
range: { start: { line: 0, character: 6 }, end: { line: 1, character: 1 } },
severity: 'Error',
source: 'playwright',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { enableConfigs, enableProjects, escapedPathSep, expect, test } from './utils';
import { enableConfigs, enableProjects, escapedPathSep, expect, test } from './baseTest';
import fs from 'fs';
import path from 'path';

Expand Down Expand Up @@ -720,6 +720,8 @@ test('should not run config reporters', async ({ activate }, testInfo) => {
});

test('should list tests in multi-folder workspace', async ({ activate }, testInfo) => {
test.fixme(true, 'multi-folder workspace not supported yet');

const { vscode, testController } = await activate({}, {
workspaceFolders: [
[testInfo.outputPath('folder1'), {
Expand Down Expand Up @@ -760,6 +762,8 @@ test('should list tests in multi-folder workspace', async ({ activate }, testInf
});

test('should not keep empty workspace-folders in a workspace', async ({ activate }, testInfo) => {
test.fixme(true, 'multi-folder workspace not supported yet');

const { testController } = await activate({}, {
workspaceFolders: [
[testInfo.outputPath('folder1'), {}],
Expand Down

0 comments on commit 9e829bb

Please sign in to comment.