Skip to content

Commit

Permalink
Use Node test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 17, 2023
1 parent b81001f commit 5ab03c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ jobs:
strategy:
matrix:
node:
- lts/fermium
- lts/gallium
- node
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"react": ">=16"
},
"devDependencies": {
"@types/node": "^18.0.0",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/react-is": "^17.0.0",
Expand All @@ -121,14 +122,13 @@
"rimraf": "^3.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"uvu": "^0.5.0",
"xo": "^0.53.0"
},
"scripts": {
"prepack": "npm run build && npm run format",
"build": "tsc --build --clean && tsc --build && type-coverage && esbuild index.js --bundle --minify --target=es2015 --outfile=react-markdown.min.js --global-name=ReactMarkdown --banner:js=\"(function (g, f) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = f() : typeof define === 'function' && define.amd ? define([], f) : (g = typeof globalThis !== 'undefined' ? globalThis : g || self, g.ReactMarkdown = f()); }(this, (function () { 'use strict';\" --footer:js=\"return ReactMarkdown;})));\"",
"format": "remark . -qfo --ignore-pattern test/ && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --no-warnings --experimental-loader=./test/loader.js --conditions development ./node_modules/.bin/uvu test \"\\.jsx$\"",
"test-api": "node --no-warnings --experimental-loader=./test/loader.js --conditions development test/test.jsx",
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
"test": "npm run build && npm run format && npm run test-coverage"
},
Expand Down
14 changes: 6 additions & 8 deletions test/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* @typedef {import('react').ReactNode} ReactNode
*/

import assert from 'node:assert/strict'
import fs from 'node:fs/promises'
import {test} from 'uvu'
import * as assert from 'uvu/assert'
import test from 'node:test'
import React from 'react'
import gfm from 'remark-gfm'
import {visit} from 'unist-util-visit'
Expand Down Expand Up @@ -728,7 +728,7 @@ test('should pass on raw source position to non-tag components if rawSourcePos o
rawSourcePos
components={{
em({node, sourcePosition, ...props}) {
assert.equal(sourcePosition, {
assert.deepEqual(sourcePosition, {
start: {line: 1, column: 1, offset: 0},
end: {line: 1, column: 6, offset: 5}
})
Expand All @@ -754,7 +754,7 @@ test('should pass on raw source position to non-tag components if rawSourcePos o
components={{
// @ts-expect-error JSX types currently only handle element returns not string returns
em({sourcePosition}) {
assert.equal(sourcePosition, {
assert.deepEqual(sourcePosition, {
start: {line: 1, column: 1, offset: 0},
end: {line: 1, column: 6, offset: 5}
})
Expand Down Expand Up @@ -1436,7 +1436,7 @@ test('should support remark plugins with array parameter', async () => {
const expected = '<p>a</p>'
assert.equal(actual, expected)

assert.not.match(message, /Warning: Failed/, 'Prop types should be valid')
assert.doesNotMatch(message, /Warning: Failed/, 'Prop types should be valid')
console.error = error
})

Expand All @@ -1459,8 +1459,6 @@ test('should support rehype plugins with array parameter', async () => {
const expected = '<p>a</p>'
assert.equal(actual, expected)

assert.not.match(message, /Warning: Failed/, 'Prop types should be valid')
assert.doesNotMatch(message, /Warning: Failed/, 'Prop types should be valid')
console.error = error
})

test.run()

0 comments on commit 5ab03c4

Please sign in to comment.