Skip to content

Commit 1b31ac0

Browse files
committed
test: e2e test based on jest snapshots, close #20
1 parent 67404c9 commit 1b31ac0

File tree

9 files changed

+132
-56
lines changed

9 files changed

+132
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
coverage
12
lib
23
node_modules
34
tsconfig.tsbuildinfo

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ script:
2020
- yarn build
2121
- yarn test
2222

23+
after_success:
24+
- yarn global add codecov
25+
- codecov
26+
2327
before_deploy:
2428
- npm set //registry.npmjs.org/:_authToken $NPM_TOKEN
2529
- git remote set-url origin https://user:[email protected]/$TRAVIS_REPO_SLUG.git

package.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@
1111
],
1212
"scripts": {
1313
"build": "tsc -b",
14-
"test": "jest",
14+
"test": "ts-node -T node_modules/.bin/jest",
1515
"lint": "EFF_NO_LINK_RULES=true eslint . --ext js,mdx,ts,tsx -f friendly"
1616
},
1717
"devDependencies": {
1818
"@commitlint/config-conventional": "^8.1.0",
1919
"@rxts/eslint-plugin-mdx": "link:packages/eslint-plugin-mdx/src",
20-
"@types/eslint": "^4.16.6",
20+
"@types/eslint": "^4.16.8",
2121
"@types/jest": "^24.0.17",
22-
"@types/node": "^12.6.9",
23-
"@types/react": "^16.8.24",
22+
"@types/node": "^12.7.1",
23+
"@types/react": "^16.9.1",
2424
"@types/unist": "^2.0.3",
2525
"babel-eslint": "^10.0.2",
2626
"commitlint": "^8.1.0",
2727
"eslint": "^6.1.0",
2828
"eslint-config-1stg": "^5.6.9",
2929
"eslint-formatter-friendly": "^7.0.0",
3030
"eslint-mdx": "link:packages/eslint-mdx/src",
31-
"eslint-plugin-jest": "^22.14.1",
32-
"husky": "^3.0.2",
31+
"eslint-plugin-jest": "^22.15.0",
32+
"husky": "^3.0.3",
3333
"jest": "^24.8.0",
3434
"lerna": "^3.16.4",
3535
"lerna-changelog": "^0.8.2",
3636
"lint-staged": "^9.2.1",
3737
"prettier": "1.18.2",
3838
"prettier-config-1stg": "^0.1.0",
39-
"react": "^16.8.6",
40-
"remark-mdx": "^1.1.5",
39+
"react": "^16.9.0",
40+
"remark-mdx": "^1.2.2",
4141
"remark-parse": "^7.0.1",
4242
"ts-jest": "^24.0.2",
4343
"ts-node": "^8.3.0",
@@ -50,6 +50,8 @@
5050
]
5151
},
5252
"eslintIgnore": [
53+
"**/fixtures/**/*.mdx",
54+
"coverage",
5355
"lib",
5456
"node_modules"
5557
],
@@ -60,10 +62,11 @@
6062
}
6163
},
6264
"jest": {
63-
"preset": "ts-jest",
65+
"collectCoverage": true,
6466
"modulePathIgnorePatterns": [
6567
"<rootDir>/packages/"
66-
]
68+
],
69+
"preset": "ts-jest"
6770
},
6871
"lint-staged": {
6972
"*.{html,json,md,scss,yml}": [
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`fixtures should match all snapshots: basic.mdx 1`] = `
4+
"import Basic from './basic'
5+
6+
export const meta = {
7+
title: 'Blog Post',
8+
}
9+
10+
# Blog Post
11+
12+
Lorem ipsum dolor sit amet, consectetur adipiscing **elit**. Ut ac lobortis <b>velit</b>.
13+
14+
<!-- This is a comment -->
15+
16+
\`\`\`css
17+
@media (min-width: 400px) {
18+
border-color: #000;
19+
}
20+
\`\`\`
21+
22+
<Basic>{/* This is a comment */}</Basic>
23+
24+
## Subtitle
25+
26+
Lorem ipsum dolor sit _amet_, consectetur adipiscing elit. Ut ac lobortis velit.
27+
"
28+
`;
29+
30+
exports[`fixtures should match all snapshots: no-jsx-html-comments.mdx 1`] = `
31+
"# Title
32+
33+
<header>Header{/** JSX HTML comment */}</header>
34+
<main>Main Content</main>
35+
"
36+
`;

test/fixtures.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { basename } from 'path'
2+
3+
import { CLIEngine } from 'eslint'
4+
5+
export const cli = new CLIEngine({
6+
ignore: false,
7+
fix: true,
8+
})
9+
10+
describe('fixtures', () => {
11+
it('should match all snapshots', () => {
12+
cli
13+
.executeOnFiles(['test/fixtures/*.mdx'])
14+
.results.forEach(({ filePath, output }) =>
15+
expect(output).toMatchSnapshot(basename(filePath)),
16+
)
17+
})
18+
})

test/fixtures/adjacent-jsx.mdx

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/fixtures/basic.mdx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Basic } from './basic'
1+
import Basic from './basic'
22

33
export const meta = {
44
title: 'Blog Post',
@@ -16,16 +16,10 @@ Lorem ipsum dolor sit amet, consectetur adipiscing **elit**. Ut ac lobortis <b>v
1616
}
1717
```
1818

19-
<Basic>{/* This is a comment */}</Basic>
20-
2119
<Basic>
22-
{/** This is a comment */}In JSX!{/** This is a comment */}
20+
{/* This is a comment */}
2321
</Basic>
2422

25-
Inline <Basic><!-- This is a comment -->In &gt;
26-
JSX!<!-- This is a
27-
comment --> &gt; <!-- This is a comment --></Basic>
28-
2923
## Subtitle
3024

3125
Lorem ipsum dolor sit _amet_, consectetur adipiscing elit. Ut ac lobortis velit.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Title
2+
3+
<header>Header<!-- JSX HTML comment --></header>
4+
<main>Main Content</main>

yarn.lock

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,11 @@
11961196
mkdirp "^0.5.1"
11971197
rimraf "^2.5.2"
11981198

1199+
"@mdx-js/util@^1.2.2":
1200+
version "1.2.2"
1201+
resolved "https://registry.yarnpkg.com/@mdx-js/util/-/util-1.2.2.tgz#4a63e82b6319ac85f455f0b8328a6e6d15ebe251"
1202+
integrity sha512-hnf0SpGr1ckKWYQt7CHkocAyeh4u7UyYt8bRdILT94ypZ0piX+By6bnDZxYysMt8V+knl7ZM0MxaPFIdrhTh0g==
1203+
11991204
"@mrmlnc/readdir-enhanced@^2.2.1":
12001205
version "2.2.1"
12011206
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
@@ -1334,10 +1339,10 @@
13341339
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
13351340
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==
13361341

1337-
"@types/eslint@^4.16.6":
1338-
version "4.16.6"
1339-
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-4.16.6.tgz#96d4ecddbea618ab0b55eaf0dffedf387129b06c"
1340-
integrity sha512-GL7tGJig55FeclpOytU7nCCqtR143jBoC7AUdH0DO9xBSIFiNNUFCY/S3KNWsHeQJuU3hjw/OC1+kRTFNXqUZQ==
1342+
"@types/eslint@^4.16.8":
1343+
version "4.16.8"
1344+
resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-4.16.8.tgz#856f0eb8a312d25a7989b6d0ab708e8d5f8cc7ee"
1345+
integrity sha512-n0ZvaIpPeBxproRvV+tZoCHRxIoNAk+k+XMvQefKgx3qM3IundoogQBAwiNEnqW0GDP1j1ATe5lFy9xxutFAHg==
13411346
dependencies:
13421347
"@types/estree" "*"
13431348
"@types/json-schema" "*"
@@ -1408,11 +1413,16 @@
14081413
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
14091414
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
14101415

1411-
"@types/node@*", "@types/node@^12.0.2", "@types/node@^12.6.9":
1416+
"@types/node@*", "@types/node@^12.0.2":
14121417
version "12.6.9"
14131418
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.6.9.tgz#ffeee23afdc19ab16e979338e7b536fdebbbaeaf"
14141419
integrity sha512-+YB9FtyxXGyD54p8rXwWaN1EWEyar5L58GlGWgtH2I9rGmLGBQcw63+0jw+ujqVavNuO47S1ByAjm9zdHMnskw==
14151420

1421+
"@types/node@^12.7.1":
1422+
version "12.7.1"
1423+
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.1.tgz#3b5c3a26393c19b400844ac422bd0f631a94d69d"
1424+
integrity sha512-aK9jxMypeSrhiYofWWBf/T7O+KwaiAHzM4sveCdWPn71lzUSMimRnKzhXDKfKwV1kWoBo2P1aGgaIYGLf9/ljw==
1425+
14161426
"@types/normalize-package-data@^2.4.0":
14171427
version "2.4.0"
14181428
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e"
@@ -1423,10 +1433,10 @@
14231433
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.1.tgz#f1a11e7babb0c3cad68100be381d1e064c68f1f6"
14241434
integrity sha512-CFzn9idOEpHrgdw8JsoTkaDDyRWk1jrzIV8djzcgpq0y9tG4B4lFT+Nxh52DVpDXV+n4+NPNv7M1Dj5uMp6XFg==
14251435

1426-
"@types/react@^16.8.24":
1427-
version "16.8.24"
1428-
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.8.24.tgz#8d1ea1fcbfa214220da3d3c04e506f1077b0deac"
1429-
integrity sha512-VpFHUoD37YNY2+lr/+c7qL/tZsIU/bKuskUF3tmGUArbxIcQdb5j3zvo4cuuzu2A6UaVmVn7sJ4PgWYNFEBGzg==
1436+
"@types/react@^16.9.1":
1437+
version "16.9.1"
1438+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.1.tgz#862c83b4c9d5cd116e42fd9a4f3694843cd2c051"
1439+
integrity sha512-jGM2x8F7m7/r+81N/BOaUKVwbC5Cdw6ExlWEUpr77XPwVeNvAppnPEnMMLMfxRDYL8FPEX8MHjwtD2NQMJ0yyQ==
14301440
dependencies:
14311441
"@types/prop-types" "*"
14321442
csstype "^2.2.0"
@@ -3027,10 +3037,10 @@ eslint-plugin-import@^2.18.2:
30273037
read-pkg-up "^2.0.0"
30283038
resolve "^1.11.0"
30293039

3030-
eslint-plugin-jest@^22.14.1:
3031-
version "22.14.1"
3032-
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.14.1.tgz#32287dade9bc0a1920c61e25a71cf11363d78015"
3033-
integrity sha512-mpLjhADl+HjagrlaGNx95HIji089S18DhnU/Ee8P8VP+dhEnuEzb43BXEaRmDgQ7BiSUPcSCvt1ydtgPkjOF/Q==
3040+
eslint-plugin-jest@^22.15.0:
3041+
version "22.15.0"
3042+
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-22.15.0.tgz#fe70bfff7eeb47ca0ab229588a867f82bb8592c5"
3043+
integrity sha512-hgnPbSqAIcLLS9ePb12hNHTRkXnkVaCfOwCt2pzQ8KpOKPWGA4HhLMaFN38NBa/0uvLfrZpcIRjT+6tMAfr58Q==
30343044
dependencies:
30353045
"@typescript-eslint/experimental-utils" "^1.13.0"
30363046

@@ -3978,10 +3988,10 @@ humanize-ms@^1.2.1:
39783988
dependencies:
39793989
ms "^2.0.0"
39803990

3981-
husky@^3.0.2:
3982-
version "3.0.2"
3983-
resolved "https://registry.yarnpkg.com/husky/-/husky-3.0.2.tgz#e78fd2ae16edca59fc88e56aeb8d70acdcc1c082"
3984-
integrity sha512-WXCtaME2x0o4PJlKY4ap8BzLA+D0zlvefqAvLCPriOOu+x0dpO5uc5tlB7CY6/0SE2EESmoZsj4jW5D09KrJoA==
3991+
husky@^3.0.3:
3992+
version "3.0.3"
3993+
resolved "https://registry.yarnpkg.com/husky/-/husky-3.0.3.tgz#6f3fb99f60ef72cdf34e5d78445c2f798c441b1d"
3994+
integrity sha512-DBBMPSiBYEMx7EVUTRE/ymXJa/lOL+WplcsV/lZu+/HHGt0gzD+5BIz9EJnCrWyUa7hkMuBh7/9OZ04qDkM+Nw==
39853995
dependencies:
39863996
chalk "^2.4.2"
39873997
cosmiconfig "^5.2.1"
@@ -3990,7 +4000,7 @@ husky@^3.0.2:
39904000
is-ci "^2.0.0"
39914001
opencollective-postinstall "^2.0.2"
39924002
pkg-dir "^4.2.0"
3993-
please-upgrade-node "^3.1.1"
4003+
please-upgrade-node "^3.2.0"
39944004
read-pkg "^5.1.1"
39954005
run-node "^1.0.0"
39964006
slash "^3.0.0"
@@ -6496,6 +6506,13 @@ please-upgrade-node@^3.1.1:
64966506
dependencies:
64976507
semver-compare "^1.0.0"
64986508

6509+
please-upgrade-node@^3.2.0:
6510+
version "3.2.0"
6511+
resolved "https://registry.yarnpkg.com/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz#aeddd3f994c933e4ad98b99d9a556efa0e2fe942"
6512+
integrity sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==
6513+
dependencies:
6514+
semver-compare "^1.0.0"
6515+
64996516
pn@^1.1.0:
65006517
version "1.1.0"
65016518
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
@@ -6677,15 +6694,14 @@ react-is@^16.8.1, react-is@^16.8.4:
66776694
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
66786695
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
66796696

6680-
react@^16.8.6:
6681-
version "16.8.6"
6682-
resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe"
6683-
integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==
6697+
react@^16.9.0:
6698+
version "16.9.0"
6699+
resolved "https://registry.yarnpkg.com/react/-/react-16.9.0.tgz#40ba2f9af13bc1a38d75dbf2f4359a5185c4f7aa"
6700+
integrity sha512-+7LQnFBwkiw+BobzOF6N//BdoNw0ouwmSJTEm9cglOOmsg/TMiFHZLe2sEoN5M7LgJTj9oHH0gxklfnQe66S1w==
66846701
dependencies:
66856702
loose-envify "^1.1.0"
66866703
object-assign "^4.1.1"
66876704
prop-types "^15.6.2"
6688-
scheduler "^0.13.6"
66896705

66906706
read-cmd-shim@^1.0.1:
66916707
version "1.0.1"
@@ -6882,6 +6898,20 @@ remark-mdx@^1.1.5:
68826898
remark-parse "7.0.0"
68836899
unified "8.3.2"
68846900

6901+
remark-mdx@^1.2.2:
6902+
version "1.2.2"
6903+
resolved "https://registry.yarnpkg.com/remark-mdx/-/remark-mdx-1.2.2.tgz#2e7efc76405999f7d3937b9011c2310326cfc74f"
6904+
integrity sha512-jkDKV2FMmIzRftMFL6YDKijr12JxsgXWgG8Slb/IKV58F6846W8WuJRonQDCOQ5QL2+1GChB7hZ4QbnNvn4ktg==
6905+
dependencies:
6906+
"@babel/core" "7.5.5"
6907+
"@babel/helper-plugin-utils" "7.0.0"
6908+
"@babel/plugin-proposal-object-rest-spread" "7.5.5"
6909+
"@babel/plugin-syntax-jsx" "7.2.0"
6910+
"@mdx-js/util" "^1.2.2"
6911+
is-alphabetical "1.0.3"
6912+
remark-parse "7.0.1"
6913+
unified "8.3.2"
6914+
68856915
68866916
version "7.0.0"
68876917
resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-7.0.0.tgz#2c4c420292eb2af6124161c931d1dfba9fbef940"
@@ -6903,7 +6933,7 @@ [email protected]:
69036933
vfile-location "^2.0.0"
69046934
xtend "^4.0.1"
69056935

6906-
remark-parse@^7.0.0, remark-parse@^7.0.1:
6936+
remark-parse@7.0.1, remark-parse@^7.0.0, remark-parse@^7.0.1:
69076937
version "7.0.1"
69086938
resolved "https://registry.yarnpkg.com/remark-parse/-/remark-parse-7.0.1.tgz#0c13d67e0d7b82c2ad2d8b6604ec5fae6c333c2b"
69096939
integrity sha512-WOZLa545jYXtSy+txza6ACudKWByQac4S2DmGk+tAGO/3XnVTOxwyCIxB7nTcLlk8Aayhcuf3cV1WV6U6L7/DQ==
@@ -7169,14 +7199,6 @@ sax@^1.2.4:
71697199
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
71707200
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
71717201

7172-
scheduler@^0.13.6:
7173-
version "0.13.6"
7174-
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889"
7175-
integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ==
7176-
dependencies:
7177-
loose-envify "^1.1.0"
7178-
object-assign "^4.1.1"
7179-
71807202
semver-compare@^1.0.0:
71817203
version "1.0.0"
71827204
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc"

0 commit comments

Comments
 (0)