diff --git a/packages/test-project/e2e/example.spec.ts b/packages/test-project/e2e/example.spec.ts index 2b99c5d..1f40da3 100644 --- a/packages/test-project/e2e/example.spec.ts +++ b/packages/test-project/e2e/example.spec.ts @@ -1,12 +1,13 @@ import { expect } from '@playwright/test'; import {test} from "obsidian-testing-framework" import {TFile} from "obsidian"; -import {assertLineEquals, doWithApp, readFile} from "obsidian-testing-framework/util"; +import {assertLineEquals, doWithApp, readFile, waitForIndexingComplete} from "obsidian-testing-framework/util"; test('something', async ({ page }) => { console.log(page.url()); expect(/obsidian\.md/i.test(page.url())).toBeTruthy() }); test("idk", async({page}) => { + await waitForIndexingComplete(page); let what = await doWithApp(page, async (app) => { return app.metadataCache.getFirstLinkpathDest("Welcome", "/"); }); @@ -16,6 +17,7 @@ test("idk", async({page}) => { }) test("file line", async({page}) => { + await waitForIndexingComplete(page); console.log(await readFile(page, "Welcome.md")) await assertLineEquals(page, "Welcome.md", 0, "This is your new *vault*."); }) diff --git a/packages/test-project/package.json b/packages/test-project/package.json index 7634f33..47e3557 100644 --- a/packages/test-project/package.json +++ b/packages/test-project/package.json @@ -9,7 +9,7 @@ "dev": "node esbuild.config.mjs", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "version": "node version-bump.mjs && git add manifest.json versions.json", - "test": "xvfb-maybe playwright test" + "test": "xvfb-maybe vitest" }, "keywords": [], "author": "", @@ -18,14 +18,14 @@ "obsidian-testing-framework": "workspace:^" }, "devDependencies": { - "@playwright/test": "^1.48.1", + "@playwright/test": "^1.58.2", "@types/node": "^16.11.6", "@typescript-eslint/eslint-plugin": "5.29.0", "@typescript-eslint/parser": "5.29.0", "builtin-modules": "3.3.0", "esbuild": "0.17.3", "obsidian": "latest", - "playwright": "^1.48.1", + "playwright": "^1.58.2", "tslib": "2.4.0", "typescript": "4.7.4", "vitest": "^4.0.18", diff --git a/packages/test-project/playwright.config.ts b/packages/test-project/playwright.config.ts deleted file mode 100644 index 0c223fa..0000000 --- a/packages/test-project/playwright.config.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { defineConfig, devices } from '@playwright/test'; -import {ObsidianTestFixtures} from "obsidian-testing-framework/fixture"; -import os from "os" -import path from 'path'; - -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// import dotenv from 'dotenv'; -// import path from 'path'; -// dotenv.config({ path: path.resolve(__dirname, '.env') }); - -/** - * See https://playwright.dev/docs/test-configuration. - */ -export default defineConfig({ - testDir: './e2e', - - /* Run tests in files in parallel */ - fullyParallel: true, - /* Fail the build on CI if you accidentally left test.only in the source code. */ - forbidOnly: !!process.env.CI, - /* Retry on CI only */ - retries: 1, - /* Opt out of parallel tests on CI. */ - workers: 1, - /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: [['html', {open: "never"}]], - /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ - use: { - /* Base URL to use in actions like `await page.goto('/')`. */ - // baseURL: 'http://127.0.0.1:3000', - - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', - obsidian: { - vault: path.resolve(process.cwd(), "..", "..", "vault") - } - - }, - outputDir: "playwright-report" - /* Configure projects for major browsers */ - - - /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, -}); diff --git a/packages/test-project/vitest.config.ts b/packages/test-project/vitest.config.ts new file mode 100644 index 0000000..39b9ae5 --- /dev/null +++ b/packages/test-project/vitest.config.ts @@ -0,0 +1,12 @@ +import path from 'path' +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + test: { + dir: "./e2e", + pool: "threads", + provide: { + vault: path.resolve(process.cwd(), "..", "..", "vault") + } + }, +})