Skip to content

Commit 5678aa0

Browse files
authored
Revert "refactor: Update test environments and lint configuration (#1736)"
This reverts commit 6728a41.
1 parent 5ecadb8 commit 5678aa0

File tree

72 files changed

+8489
-32242
lines changed

Some content is hidden

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

72 files changed

+8489
-32242
lines changed

Diff for: .eslintignore

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.git
2-
**/*.md
3-
build
4-
docs
5-
lib
6-
node_modules
72
packages/docsify-server-renderer/build.js
3+
node_modules
4+
build
85
server.js
6+
lib
97
themes
8+
build
9+
docs/
10+
**/*.md

Diff for: .eslintrc.js

+10-24
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
const prettierConfig = require('./.prettierrc');
2-
31
module.exports = {
42
root: true,
5-
extends: [
6-
'eslint:recommended',
7-
'plugin:import/recommended',
8-
'plugin:prettier/recommended', // Must be last
9-
],
10-
parser: '@babel/eslint-parser',
3+
parser: 'babel-eslint',
114
parserOptions: {
125
sourceType: 'module',
136
ecmaVersion: 2019,
147
},
15-
plugins: ['prettier', 'import'],
168
env: {
179
browser: true,
18-
es6: true,
1910
node: true,
11+
es6: true,
2012
},
13+
plugins: ['prettier', 'import'],
14+
extends: ['eslint:recommended', 'plugin:import/recommended'],
2115
settings: {
2216
'import/ignore': ['node_modules', '.json$'],
2317
},
2418
rules: {
19+
'prettier/prettier': ['error'],
2520
camelcase: ['warn'],
21+
'no-useless-escape': ['warn'],
2622
curly: ['error', 'all'],
2723
'dot-notation': ['error'],
2824
eqeqeq: ['error'],
@@ -37,16 +33,9 @@ module.exports = {
3733
'no-proto': ['error'],
3834
'no-return-assign': ['error'],
3935
'no-self-compare': ['error'],
36+
'no-shadow': ['warn'],
4037
'no-shadow-restricted-names': ['error'],
41-
'no-shadow': [
42-
'error',
43-
{
44-
allow: ['Events', 'Fetch', 'Lifecycle', 'Render', 'Router'],
45-
},
46-
],
47-
'no-unused-vars': ['error', { args: 'none' }],
4838
'no-useless-call': ['error'],
49-
'no-useless-escape': ['warn'],
5039
'no-var': ['error'],
5140
'no-void': ['error'],
5241
'no-with': ['error'],
@@ -57,21 +46,18 @@ module.exports = {
5746

5847
// Import rules
5948
// Search way how integrate with `lerna`
49+
'import/no-unresolved': 'off',
6050
'import/imports-first': ['error'],
6151
'import/newline-after-import': ['error'],
6252
'import/no-duplicates': ['error'],
6353
'import/no-mutable-exports': ['error'],
64-
'import/no-named-as-default-member': ['error'],
6554
'import/no-named-as-default': ['error'],
66-
'import/no-unresolved': 'off',
55+
'import/no-named-as-default-member': ['error'],
6756
'import/order': ['warn'],
68-
69-
// Prettier (Must be last)
70-
'prettier/prettier': ['warn', prettierConfig],
7157
},
7258
globals: {
73-
$docsify: 'writable',
7459
Docsify: 'writable',
60+
$docsify: 'writable',
7561
dom: 'writable',
7662
},
7763
};

Diff for: .github/workflows/lint.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- develop
8+
pull_request:
9+
branches:
10+
- master
11+
- develop
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
node-version: [12.x, 14.x]
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Use Node.js ${{ matrix.node-version }}
24+
uses: actions/setup-node@v1
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
- name: Install
28+
run: npm i --ignore-scripts
29+
- name: Lint
30+
run: npm run lint

Diff for: .github/workflows/test.yml

+22-59
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,41 @@ name: Build & Test
22

33
on:
44
push:
5-
branches: [master, develop]
5+
branches:
6+
- master
7+
- develop
68
pull_request:
7-
branches: [master, develop]
9+
branches:
10+
- master
11+
- develop
812

913
jobs:
10-
lint:
11-
runs-on: ubuntu-latest
12-
strategy:
13-
matrix:
14-
node-version: ['lts/*']
15-
steps:
16-
- uses: actions/checkout@v2
17-
- name: Setup Node.js ${{ matrix.node-version }}
18-
uses: actions/setup-node@v2
19-
with:
20-
node-version: ${{ matrix.node-version }}
21-
cache: 'npm'
22-
- name: Install dependencies
23-
run: npm ci --ignore-scripts
24-
- name: Build
25-
run: npm run build
26-
- name: Lint
27-
run: npm run lint
28-
29-
test-jest:
14+
build:
3015
runs-on: ${{ matrix.os }}
3116
strategy:
3217
fail-fast: false
3318
matrix:
34-
node-version: ['lts/*']
19+
node-version: [12.x, 14.x]
3520
os: ['macos-latest', 'ubuntu-latest', 'windows-latest']
36-
steps:
37-
- uses: actions/checkout@v2
38-
- name: Setup Node.js ${{ matrix.node-version }}
39-
uses: actions/setup-node@v2
40-
with:
41-
node-version: ${{ matrix.node-version }}
42-
cache: 'npm'
43-
- name: Install dependencies
44-
run: npm ci --ignore-scripts
45-
- name: Build
46-
run: npm run build
47-
- name: Unit Tests
48-
run: npm run test:unit -- --ci --runInBand
49-
- name: Integration Tests
50-
run: npm run test:integration -- --ci --runInBand
5121

52-
test-playwright:
53-
runs-on: ubuntu-latest
54-
strategy:
55-
matrix:
56-
node-version: ['lts/*']
5722
steps:
5823
- uses: actions/checkout@v2
59-
- name: Setup Node.js ${{ matrix.node-version }}
60-
uses: actions/setup-node@v2
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v1
6126
with:
6227
node-version: ${{ matrix.node-version }}
63-
cache: 'npm'
64-
- name: Install dependencies
65-
run: npm ci --ignore-scripts
66-
- name: Build
67-
run: npm run build
68-
- name: Install Playwright
69-
run: npx playwright install --with-deps
70-
- name: E2E Tests (Playwright)
71-
run: npm run test:e2e
72-
- name: Store artifacts
28+
- name: bootstrap
29+
run: npm run bootstrap
30+
- name: unit tests
31+
run: npm run test:unit -- -ci --runInBand
32+
- name: integration tests
33+
run: npm run test:integration -- -ci --runInBand
34+
- uses: microsoft/playwright-github-action@v1
35+
- name: e2e tests
36+
run: npm run test:e2e -- --ci --runInBand
37+
- name: Upload artifacts (diff output)
7338
uses: actions/upload-artifact@v2
7439
if: failure()
7540
with:
76-
name: ${{ matrix.os }}-${{ matrix.node-version }}-artifacts
77-
path: |
78-
_playwright-results/
79-
_playwright-report/
41+
name: ${{ matrix.os }}-${{ matrix.node-version }}-diff-output
42+
path: ${{ github.workspace }}/test/**/__diff_output__/*

Diff for: .gitignore

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
*.log
12
.DS_Store
23
.idea
3-
*.log
4-
_playwright-report
5-
_playwright-results
6-
lib
4+
__diff_output__
5+
lib/
76
node_modules
8-
themes
7+
themes/
98

109
# exceptions
1110
!.gitkeep

Diff for: .npmignore

+1-1
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

Diff for: .prettierrc.js

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

Diff for: .vscode/settings.json

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

Diff for: jest.config.js

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

33
const sharedConfig = {
44
errorOnDeprecated: true,
5+
globals: {
6+
TEST_HOST,
7+
},
58
globalSetup: './test/config/jest.setup.js',
69
globalTeardown: './test/config/jest.teardown.js',
710
resetModules: true,
811
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,
1519
projects: [
16-
// Unit Tests
20+
// Unit Tests (Jest)
1721
{
18-
displayName: 'unit',
1922
...sharedConfig,
23+
displayName: 'unit',
24+
setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'],
2025
testMatch: ['<rootDir>/test/unit/*.test.js'],
26+
testURL: `${TEST_HOST}/_blank.html`,
2127
},
22-
// Integration Tests
28+
// Integration Tests (Jest)
2329
{
24-
displayName: 'integration',
2530
...sharedConfig,
31+
displayName: 'integration',
32+
setupFilesAfterEnv: ['<rootDir>/test/config/jest.setup-tests.js'],
2633
testMatch: ['<rootDir>/test/integration/*.test.js'],
34+
testURL: `${TEST_HOST}/_blank.html`,
35+
},
36+
// E2E Tests (Jest + Playwright)
37+
{
38+
...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'],
2759
},
2860
],
2961
};

0 commit comments

Comments
 (0)