refactor(example): move from playwright to vitest
This commit is contained in:
parent
8999a95240
commit
e150100acc
@ -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<TFile | null>(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*.");
|
||||
})
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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<ObsidianTestFixtures>({
|
||||
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,
|
||||
// },
|
||||
});
|
||||
12
packages/test-project/vitest.config.ts
Normal file
12
packages/test-project/vitest.config.ts
Normal file
@ -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")
|
||||
}
|
||||
},
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user