Skip to content

Commit

Permalink
fix: support mocha 9 (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
dword-design authored Jun 9, 2021
1 parent da61e86 commit 7683922
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 84 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
"@dword-design/functions": "^4.0.0"
},
"devDependencies": {
"@dword-design/base": "^8.0.0"
"@dword-design/base": "^8.0.0",
"@dword-design/tester": "^2.0.4",
"@dword-design/tester-plugin-tmp-dir": "^2.0.3",
"execa": "^5.1.1",
"fs-extra": "^10.0.0",
"mocha": "^9.0.0"
},
"engines": {
"node": ">=12"
Expand Down
45 changes: 45 additions & 0 deletions src/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`index 0 1`] = `
"
index
✓ test1
✓ test2
2 passing
"
`;

exports[`index 1 1`] = `
"
index
✓ test1
✓ test2
2 passing
"
`;

exports[`index 2 1`] = `
"
index
✓ test
1 passing
"
`;

exports[`index 3 1`] = `
"
index
✓ test1
✓ test2
2 passing
"
`;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { replace } from '@dword-design/functions'

export default x => x |> replace(/ \(\d+m?s\)/g, '') |> replace(//g, '✓')
export default x => x |> replace(/ \(\d+m?s\)/g, '') |> replace(/(√|✔)/g, '✓')
113 changes: 46 additions & 67 deletions src/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,33 @@
import { endent } from '@dword-design/functions'
import { endent, property } from '@dword-design/functions'
import tester from '@dword-design/tester'
import testerPluginTmpDir from '@dword-design/tester-plugin-tmp-dir'
import execa from 'execa'
import { outputFile } from 'fs-extra'
import P from 'path'

import self from '.'

export default [
() =>
expect(
self(endent`
index
✓ test1
✓ test2
2 passing (7ms)
`)
).toEqual(endent`
index
✓ test1
✓ test2
export default tester(
[
async function () {
await outputFile(
P.join('test', 'test.js'),
endent`
const { delay } = require('@dword-design/functions')
describe('index', () => {
it('test1', () => delay(50))
it('test2', () => delay(50))
})
`
)

2 passing
`),
() =>
expect(
self(endent`
index
√ test1
√ test2
2 passing (7ms)
`)
).toEqual(endent`
index
✓ test1
✓ test2
2 passing
`),
() =>
expect(
self(endent`
const output = execa.command('mocha') |> await |> property('stdout')
expect(output |> self).toMatchSnapshot(this)
},
function () {
expect(
self(endent`
index
✓ test1 (1000ms)
Expand All @@ -59,19 +37,11 @@ export default [
2 passing
`)
).toEqual(endent`
index
✓ test1
✓ test2
2 passing
`),
() =>
expect(
self(endent`
).toMatchSnapshot(this)
},
function () {
expect(
self(endent`
index
✓ test (2s)
Expand All @@ -80,13 +50,22 @@ export default [
1 passing
`)
).toEqual(endent`
).toMatchSnapshot(this)
},
function () {
expect(
self(endent`
index
✓ test
1 passing
√ test1
√ test2
2 passing (7ms)
`),
]
`)
).toMatchSnapshot(this)
},
],
[testerPluginTmpDir()]
)
Loading

0 comments on commit 7683922

Please sign in to comment.