Merge pull request #692 from toeverything/chore/remove-jest

chore: remove jest; using playwright over whole project
This commit is contained in:
DarkSky
2023-01-09 14:01:57 +08:00
committed by GitHub
35 changed files with 71 additions and 1349 deletions

View File

@@ -1,5 +1,4 @@
**/webpack.config.js **/webpack.config.js
**/jest.config.js
**/scripts/*.js **/scripts/*.js
**/node_modules/** **/node_modules/**
.github/** .github/**

View File

@@ -36,7 +36,7 @@ jobs:
scope: '@toeverything' scope: '@toeverything'
cache: 'pnpm' cache: 'pnpm'
- run: node scripts/module-resolve/ci.js - run: node scripts/module-resolve/ci.cjs
- name: Restore cache - name: Restore cache
uses: actions/cache@v3 uses: actions/cache@v3

View File

@@ -244,7 +244,7 @@ jobs:
scope: '@toeverything' scope: '@toeverything'
cache: 'pnpm' cache: 'pnpm'
- run: node scripts/module-resolve/ci.js - run: node scripts/module-resolve/ci.cjs
- name: Restore cache - name: Restore cache
uses: actions/cache@v3 uses: actions/cache@v3

View File

@@ -23,7 +23,7 @@ jobs:
scope: '@toeverything' scope: '@toeverything'
cache: 'pnpm' cache: 'pnpm'
- run: node scripts/module-resolve/ci.js - run: node scripts/module-resolve/ci.cjs
- name: Install dependencies - name: Install dependencies
run: pnpm install --no-frozen-lockfile run: pnpm install --no-frozen-lockfile

1
.gitignore vendored
View File

@@ -48,6 +48,7 @@ Thumbs.db
out/ out/
module-resolve.js module-resolve.js
module-resolve.cjs
/test-results/ /test-results/
/playwright-report/ /playwright-report/
/playwright/.cache/ /playwright/.cache/

View File

@@ -1,11 +1,11 @@
const fs = require('fs'); const fs = require('fs');
function getCustomize() { function getCustomize() {
const customed = fs.existsSync('./module-resolve.js'); const customed = fs.existsSync('./module-resolve.cjs');
if (!customed) { if (!customed) {
return null; return null;
} }
const script = require('./module-resolve.js'); const script = require('./module-resolve.cjs');
return script && script.resolve; return script && script.resolve;
} }

View File

@@ -1,19 +0,0 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
projects: ['<rootDir>/packages/app'],
preset: 'ts-jest',
testEnvironment: 'node',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
transform: {
// '^.+\\.[tj]sx?$' to process js/ts with `ts-jest`
// '^.+\\.m?[tj]sx?$' to process js/ts/mjs/mts with `ts-jest`
'^.+\\.tsx?$': [
'ts-jest',
{
useESM: true,
},
],
},
};

View File

@@ -4,6 +4,7 @@
"private": true, "private": true,
"author": "toeverything", "author": "toeverything",
"license": "MPL-2.0", "license": "MPL-2.0",
"type": "module",
"scripts": { "scripts": {
"dev": "pnpm --filter=!@affine/app build && pnpm --filter @affine/app dev", "dev": "pnpm --filter=!@affine/app build && pnpm --filter @affine/app dev",
"dev:ac": "pnpm --filter=!@affine/app build && NODE_API_SERVER=ac pnpm --filter @affine/app dev", "dev:ac": "pnpm --filter=!@affine/app build && NODE_API_SERVER=ac pnpm --filter @affine/app dev",
@@ -15,7 +16,7 @@
"test": "playwright test", "test": "playwright test",
"test:dc": "pnpm --filter @affine/datacenter test", "test:dc": "pnpm --filter @affine/datacenter test",
"test:e2e:codegen": "npx playwright codegen http://localhost:8080", "test:e2e:codegen": "npx playwright codegen http://localhost:8080",
"test:unit": "jest", "test:unit": "playwright test --config=playwright.config.unit.ts",
"postinstall": "husky install", "postinstall": "husky install",
"notify": "node --experimental-modules scripts/notify.mjs", "notify": "node --experimental-modules scripts/notify.mjs",
"check:ci": "pnpm lint & pnpm test" "check:ci": "pnpm lint & pnpm test"
@@ -26,7 +27,6 @@
}, },
"devDependencies": { "devDependencies": {
"@changesets/cli": "^2.26.0", "@changesets/cli": "^2.26.0",
"@jest/globals": "^29.3.1",
"@playwright/test": "^1.29.1", "@playwright/test": "^1.29.1",
"@types/eslint": "^8.4.10", "@types/eslint": "^8.4.10",
"@types/node": "^18.11.17", "@types/node": "^18.11.17",
@@ -38,10 +38,8 @@
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"got": "^12.5.3", "got": "^12.5.3",
"husky": "^8.0.2", "husky": "^8.0.2",
"jest": "^29.3.1",
"lint-staged": "^13.1.0", "lint-staged": "^13.1.0",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"ts-jest": "^29.0.3",
"typescript": "^4.9.3" "typescript": "^4.9.3"
}, },
"eslintConfig": { "eslintConfig": {

View File

@@ -1,5 +0,0 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};

View File

@@ -1,7 +1,7 @@
import { describe, test, expect } from '@jest/globals'; import { test, expect } from '@playwright/test';
import { printer } from './../printer'; import { printer } from './../printer';
const chalk = require('chalk'); const chalk = require('chalk');
describe('printer', () => { test.describe('printer', () => {
test('test debug', () => { test('test debug', () => {
expect(printer.debug('test debug')).toBe( expect(printer.debug('test debug')).toBe(
chalk.green`debug` + chalk.white(' - test debug') chalk.green`debug` + chalk.white(' - test debug')

View File

@@ -1,7 +1,7 @@
import { describe, test, expect } from '@jest/globals'; import { test, expect } from '@playwright/test';
import { isMobile } from '../get-is-mobile'; import { isMobile } from '../get-is-mobile';
describe('get-is-mobile', () => { test.describe('get-is-mobile', () => {
test('get-is-mobile', () => { test('get-is-mobile', () => {
expect( expect(
isMobile( isMobile(

View File

@@ -10,8 +10,8 @@
".": "./dist/src/index.js" ".": "./dist/src/index.js"
}, },
"scripts": { "scripts": {
"build": "tsc --project ./tsconfig.json", "dev": "tsc --project ./tsconfig.json -w",
"test": "playwright test" "build": "tsc --project ./tsconfig.json"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
@@ -26,8 +26,8 @@
"typescript": "^4.8.4" "typescript": "^4.8.4"
}, },
"dependencies": { "dependencies": {
"@blocksuite/blocks": "=0.3.1-20230106060050-1aad55d", "@blocksuite/blocks": "^0.3.1-20230109032243-37ad3ba",
"@blocksuite/store": "=0.3.1-20230106060050-1aad55d", "@blocksuite/store": "^0.3.1-20230109032243-37ad3ba",
"debug": "^4.3.4", "debug": "^4.3.4",
"encoding": "^0.1.13", "encoding": "^0.1.13",
"firebase": "^9.15.0", "firebase": "^9.15.0",
@@ -38,5 +38,9 @@
"swr": "^2.0.0", "swr": "^2.0.0",
"yjs": "^13.5.44", "yjs": "^13.5.44",
"y-protocols": "^1.0.5" "y-protocols": "^1.0.5"
},
"peerDependencies": {
"@blocksuite/blocks": "0.3.1-*",
"@blocksuite/store": "0.3.1-*"
} }
} }

View File

@@ -1,7 +1,10 @@
/**
* For unit tests.
*/
import type { PlaywrightTestConfig } from '@playwright/test'; import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = { const config: PlaywrightTestConfig = {
testDir: './tests', testDir: './packages/',
timeout: 30 * 1000, timeout: 30 * 1000,
expect: { expect: {
/** /**

1272
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,12 +2,9 @@ const fs = require('fs');
const path = require('path'); const path = require('path');
const templatePath = path.resolve(__dirname, 'module-resolve.tmpl.js'); const templatePath = path.resolve(__dirname, 'module-resolve.tmpl.js');
const destinationPath = path.resolve(__dirname, '../../module-resolve.js'); const destinationPath = path.resolve(__dirname, '../../module-resolve.cjs');
console.log('template path', templatePath); console.log('template path', templatePath);
console.log('destination path', destinationPath); console.log('destination path', destinationPath);
fs.copyFileSync( fs.copyFileSync(templatePath, destinationPath);
templatePath,
destinationPath
);

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { clickPageMoreActions } from './libs/page-logic'; import { clickPageMoreActions } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('Change page mode(Paper or Edgeless)', () => { test.describe('Change page mode(Paper or Edgeless)', () => {

View File

@@ -1,11 +1,17 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import pkg from './../packages/app/package.json';
loadPage(); loadPage();
test.describe('web console', () => { test.describe('web console', () => {
test('editor version', async ({ page }) => { // TODO: playwright need to support json import in esm
test.skip('editor version', async ({ page }) => {
// TODO: playwright need to support json import in esm
// const pkg = await import('./../packages/app/package.json', {
// assert: { type: 'json' },
// });
const pkg = {} as any;
// https://playwright.dev/docs/evaluating // https://playwright.dev/docs/evaluating
// https://github.com/microsoft/playwright/issues/13059 // https://github.com/microsoft/playwright/issues/13059
// Get the handle to a specific function. // Get the handle to a specific function.

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage } from './libs/page-logic'; import { newPage } from './libs/page-logic.js';
loadPage(); loadPage();

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage, clickPageMoreActions } from './libs/page-logic'; import { newPage, clickPageMoreActions } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('Local first export page', () => { test.describe('Local first export page', () => {

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage, clickPageMoreActions } from './libs/page-logic'; import { newPage, clickPageMoreActions } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('Local first favorite and cancel favorite page', () => { test.describe('Local first favorite and cancel favorite page', () => {

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage, clickPageMoreActions } from './libs/page-logic'; import { newPage, clickPageMoreActions } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('Local first favorite items ui', () => { test.describe('Local first favorite items ui', () => {

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage } from './libs/page-logic'; import { newPage } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('local first new page', () => { test.describe('local first new page', () => {

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage } from './libs/page-logic'; import { newPage } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('local first new page', () => { test.describe('local first new page', () => {

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage } from './libs/page-logic'; import { newPage } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('Local first delete page', () => { test.describe('Local first delete page', () => {

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage, clickPageMoreActions } from './libs/page-logic'; import { newPage, clickPageMoreActions } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('Local first delete page', () => { test.describe('Local first delete page', () => {

View File

@@ -1,6 +1,6 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { newPage } from './libs/page-logic'; import { newPage } from './libs/page-logic.js';
loadPage(); loadPage();
test.describe('Local first trash page', () => { test.describe('Local first trash page', () => {

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();

View File

@@ -1,7 +1,7 @@
import { test, expect, type Page } from '@playwright/test'; import { test, expect, type Page } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
import { withCtrlOrMeta } from './libs/keyboard'; import { withCtrlOrMeta } from './libs/keyboard.js';
import { newPage } from './libs/page-logic'; import { newPage } from './libs/page-logic.js';
loadPage(); loadPage();
const openQuickSearchByShortcut = async (page: Page) => const openQuickSearchByShortcut = async (page: Page) =>

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();

View File

@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { loadPage } from './libs/load-page'; import { loadPage } from './libs/load-page.js';
loadPage(); loadPage();