使用playwright内置test
This commit is contained in:
parent
79bb32bc6c
commit
b2321c7ee7
@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"require":"ts-node/register",
|
|
||||||
"spec":"./tests/**/*.ts"
|
|
||||||
}
|
|
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"recommendations": [
|
"recommendations": [
|
||||||
"Orta.vscode-jest",
|
"ms-playwright.playwright",
|
||||||
],
|
],
|
||||||
"unwantedRecommendations": []
|
"unwantedRecommendations": []
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
* GIT
|
* GIT
|
||||||
* vscode
|
* vscode
|
||||||
* nodejs
|
* nodejs
|
||||||
* vscode-jest插件
|
* vscode playwright 插件
|
||||||
|
|
||||||
### 安装依赖
|
### 安装依赖
|
||||||
```
|
```
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
const esModules = ['.*\\.mjs$', 'lodash-es'].join('|');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
transform: {
|
|
||||||
// '^.+\\.vue$': '@vue/vue2-jest', // Update to match your installed version
|
|
||||||
'^.+\\.(t|j)sx?$': '@swc/jest',
|
|
||||||
},
|
|
||||||
extensionsToTreatAsEsm: ['.ts', '.tsx'], // .vue
|
|
||||||
// testEnvironment: '@happy-dom/jest-environment',
|
|
||||||
moduleNameMapper: {
|
|
||||||
// '@/(.*)': '<rootDir>/src/$1',
|
|
||||||
},
|
|
||||||
transformIgnorePatterns: [`node_modules/(?!${esModules})`],
|
|
||||||
};
|
|
@ -6,16 +6,14 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"init": "playwright install",
|
"init": "playwright install",
|
||||||
"codegen": "playwright codegen",
|
"codegen": "playwright codegen",
|
||||||
"test": "jest"
|
"test": "playwright test"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"packageManager": "pnpm@9.1.1+sha1.09ada6cd05003e0ced25fb716f9fda4063ec2e3b",
|
"packageManager": "pnpm@9.1.1+sha1.09ada6cd05003e0ced25fb716f9fda4063ec2e3b",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jest/globals": "^29.7.0",
|
"@playwright/test": "^1.45.3",
|
||||||
"@swc/core": "^1.7.4",
|
"@types/node": "^22.0.2",
|
||||||
"@swc/jest": "^0.2.36",
|
|
||||||
"jest": "^29.7.0",
|
|
||||||
"playwright": "^1.45.3",
|
"playwright": "^1.45.3",
|
||||||
"typescript": "^5.5.4"
|
"typescript": "^5.5.4"
|
||||||
}
|
}
|
||||||
|
68
playwright-report/index.html
Normal file
68
playwright-report/index.html
Normal file
File diff suppressed because one or more lines are too long
42
playwright.config.ts
Normal file
42
playwright.config.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { defineConfig, devices } from '@playwright/test';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
// Look for test files in the "tests" directory, relative to this configuration file.
|
||||||
|
testDir: 'tests',
|
||||||
|
|
||||||
|
// Run all tests 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: process.env.CI ? 2 : 0,
|
||||||
|
|
||||||
|
// Opt out of parallel tests on CI.
|
||||||
|
// workers: process.env.CI ? 1 : undefined,
|
||||||
|
|
||||||
|
// Reporter to use
|
||||||
|
reporter: 'html',
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
// trace: 'on-first-retry',
|
||||||
|
// },
|
||||||
|
// Configure projects for major browsers.
|
||||||
|
// projects: [
|
||||||
|
// {
|
||||||
|
// name: 'chromium',
|
||||||
|
// use: { ...devices['Desktop Chrome'] },
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// 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,
|
||||||
|
// },
|
||||||
|
});
|
2627
pnpm-lock.yaml
2627
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
|||||||
import { describe, it, expect } from '@jest/globals'
|
import { test } from '@playwright/test'
|
||||||
import { chromium } from "playwright";
|
import { chromium } from "playwright";
|
||||||
|
|
||||||
describe("mes登录", function () {
|
test.describe("mes登录", function () {
|
||||||
|
|
||||||
it('login', async function () {
|
test('login', async function () {
|
||||||
const browser = await chromium.launch({
|
const browser = await chromium.launch({
|
||||||
// headless: false
|
// headless: false
|
||||||
});
|
});
|
||||||
@ -32,7 +32,7 @@ describe("mes登录", function () {
|
|||||||
|
|
||||||
await page.waitForTimeout(1000)
|
await page.waitForTimeout(1000)
|
||||||
let path = await page.evaluateHandle(()=>window.location.hash.substr(1))
|
let path = await page.evaluateHandle(()=>window.location.hash.substr(1))
|
||||||
expect(await path.jsonValue()).toEqual('/dashboard')
|
test.expect(await path.jsonValue()).toEqual('/dashboard')
|
||||||
|
|
||||||
|
|
||||||
// ---------------------
|
// ---------------------
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { describe, it, expect } from '@jest/globals'
|
import { test } from '@playwright/test'
|
||||||
import { chromium } from "playwright";
|
import { chromium } from "playwright";
|
||||||
|
|
||||||
describe('平台', function(){
|
test.describe('平台', function(){
|
||||||
|
|
||||||
it('登陆', async function(){
|
test('登陆', async function(){
|
||||||
|
|
||||||
const browser = await chromium.launch({
|
const browser = await chromium.launch({
|
||||||
// headless: false
|
// headless: false
|
||||||
@ -30,7 +30,7 @@ describe('平台', function(){
|
|||||||
|
|
||||||
let path = await page.evaluateHandle(()=>window.location.pathname);
|
let path = await page.evaluateHandle(()=>window.location.pathname);
|
||||||
|
|
||||||
expect(await path.jsonValue()).not.toEqual('/user-login.html')
|
test.expect(await path.jsonValue()).not.toEqual('/user-login.html')
|
||||||
|
|
||||||
// ---------------------
|
// ---------------------
|
||||||
await context.close();
|
await context.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user