Skip to content

Commit e58b74d

Browse files
committed
Update test environments and lint configuration
Update Jest (unit + integration) and Playwright (e2e) test environments. Includes stability improvements for e2e tests using newer, more stable methods per the Playwright docs. - Update Jest 26 => 27 - Update Jest-related libs (babel parser) - Update Playwright 1.8 => Playwright Test 1.18 - Update ESLint 5 => 8 - Update ESLint-related libs (parser, prettier, Jest, Playwright) - Fix e2e stability issues by replacing PW `$` method calls - Refactor e2e test runner from Jest to Playwright Test - Refactor e2e test files for Playwright Test - Refactor `fix-lint` script name to `lint:fix` for consistency - Refactor npm scripts order for readability - Remove unnecessary configs and libs - Remove example image snapshots
1 parent e0bead3 commit e58b74d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+33045
-9302
lines changed

.eslintignore

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
.git
2-
packages/docsify-server-renderer/build.js
3-
node_modules
2+
**/*.md
43
build
5-
server.js
4+
docs
65
lib
6+
node_modules
7+
packages/docsify-server-renderer/build.js
8+
server.js
79
themes
8-
build
9-
docs/
10-
**/*.md

.eslintrc.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1+
const prettierConfig = require('./.prettierrc');
2+
13
module.exports = {
24
root: true,
3-
parser: 'babel-eslint',
5+
extends: [
6+
'eslint:recommended',
7+
'plugin:import/recommended',
8+
'plugin:prettier/recommended', // Must be last
9+
],
10+
parser: '@babel/eslint-parser',
411
parserOptions: {
512
sourceType: 'module',
613
ecmaVersion: 2019,
714
},
15+
plugins: ['prettier', 'import'],
816
env: {
917
browser: true,
10-
node: true,
1118
es6: true,
19+
node: true,
1220
},
13-
plugins: ['prettier', 'import'],
14-
extends: ['eslint:recommended', 'plugin:import/recommended'],
1521
settings: {
1622
'import/ignore': ['node_modules', '.json$'],
1723
},
1824
rules: {
19-
'prettier/prettier': ['error'],
2025
camelcase: ['warn'],
21-
'no-useless-escape': ['warn'],
2226
curly: ['error', 'all'],
2327
'dot-notation': ['error'],
2428
eqeqeq: ['error'],
@@ -33,9 +37,11 @@ module.exports = {
3337
'no-proto': ['error'],
3438
'no-return-assign': ['error'],
3539
'no-self-compare': ['error'],
36-
'no-shadow': ['warn'],
3740
'no-shadow-restricted-names': ['error'],
41+
'no-shadow': ['warn'],
42+
'no-unused-vars': ['error', { args: 'none' }],
3843
'no-useless-call': ['error'],
44+
'no-useless-escape': ['warn'],
3945
'no-var': ['error'],
4046
'no-void': ['error'],
4147
'no-with': ['error'],
@@ -46,18 +52,21 @@ module.exports = {
4652

4753
// Import rules
4854
// Search way how integrate with `lerna`
49-
'import/no-unresolved': 'off',
5055
'import/imports-first': ['error'],
5156
'import/newline-after-import': ['error'],
5257
'import/no-duplicates': ['error'],
5358
'import/no-mutable-exports': ['error'],
54-
'import/no-named-as-default': ['error'],
5559
'import/no-named-as-default-member': ['error'],
60+
'import/no-named-as-default': ['error'],
61+
'import/no-unresolved': 'off',
5662
'import/order': ['warn'],
63+
64+
// Prettier (Must be last)
65+
'prettier/prettier': ['warn', prettierConfig],
5766
},
5867
globals: {
59-
Docsify: 'writable',
6068
$docsify: 'writable',
69+
Docsify: 'writable',
6170
dom: 'writable',
6271
},
6372
};

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
*.log
21
.DS_Store
32
.idea
3+
*.log
44
__diff_output__
5-
lib/
5+
_playwright-report
6+
_playwright-results
7+
lib
68
node_modules
7-
themes/
9+
themes
810

911
# exceptions
1012
!.gitkeep

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.eslintignore
22
.eslintrc
3-
.github/
3+
.github
44
.gitignore
55
.travis.yml

.prettierrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = {
2+
arrowParens: 'avoid',
23
singleQuote: true,
3-
trailingComma: 'es5',
44
};

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"editor.defaultFormatter": "esbenp.prettier-vscode"
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"cSpell.words": ["coverpage"]
34
}

jest.config.js

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,28 @@ const { TEST_HOST } = require('./test/config/server.js');
22

33
const sharedConfig = {
44
errorOnDeprecated: true,
5-
globals: {
6-
TEST_HOST,
7-
},
85
globalSetup: './test/config/jest.setup.js',
96
globalTeardown: './test/config/jest.teardown.js',
107
resetModules: true,
118
restoreMocks: true,
9+
setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'],
10+
testEnvironment: 'jsdom',
11+
testURL: `${TEST_HOST}/_blank.html`,
1212
};
1313

1414
module.exports = {
15-
// Adding globals to config root for easier importing into .eslint.js, but
16-
// as of Jest 26.4.2 these globals need to be added to each project config
17-
// as well.
18-
globals: sharedConfig.globals,
1915
projects: [
20-
// Unit Tests (Jest)
16+
// Unit Tests
2117
{
22-
...sharedConfig,
2318
displayName: 'unit',
24-
setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'],
19+
...sharedConfig,
2520
testMatch: ['<rootDir>/test/unit/*.test.js'],
26-
testURL: `${TEST_HOST}/_blank.html`,
2721
},
28-
// Integration Tests (Jest)
22+
// Integration Tests
2923
{
30-
...sharedConfig,
3124
displayName: 'integration',
32-
setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'],
33-
testMatch: ['<rootDir>/test/integration/*.test.js'],
34-
testURL: `${TEST_HOST}/_blank.html`,
35-
},
36-
// E2E Tests (Jest + Playwright)
37-
{
3825
...sharedConfig,
39-
displayName: 'e2e',
40-
preset: 'jest-playwright-preset',
41-
setupFilesAfterEnv: [
42-
'<rootDir>/test/config/jest-playwright.setup-tests.js',
43-
],
44-
testEnvironmentOptions: {
45-
'jest-playwright': {
46-
// prettier-ignore
47-
browsers: [
48-
'chromium',
49-
'firefox',
50-
'webkit',
51-
],
52-
launchOptions: {
53-
// headless: false,
54-
// devtools: true,
55-
},
56-
},
57-
},
58-
testMatch: ['<rootDir>/test/e2e/*.test.js'],
26+
testMatch: ['<rootDir>/test/integration/*.test.js'],
5927
},
6028
],
6129
};

0 commit comments

Comments
 (0)