Skip to content

Commit da979d6

Browse files
committed
fix: make tests run in CI without tty
1 parent fbcaaed commit da979d6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"build": "npm run lint",
99
"lint": "standard",
10-
"test": "mocha test/*.spec.js"
10+
"test": "npm run lint && mocha test/*.spec.js"
1111
},
1212
"keywords": [],
1313
"author": "Mikeal Rogers <[email protected]> (https://www.mikealrogers.com/)",

test/basics.spec.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { CID } from 'multiformats/cid'
44
import { assert } from 'chai'
55
import printify from '../index.js'
6+
import { supportsColor } from 'chalk'
67

78
it('all', () => {
89
const str = printify({
@@ -19,5 +20,10 @@ it('all', () => {
1920
]
2021
}
2122
})
22-
assert.equal(str, '{\n \u001b[32mone\u001b[39m: \u001b[31m1\u001b[39m\n \u001b[32mtwo\u001b[39m: \u001b[31m"two"\u001b[39m\n \u001b[32mthree\u001b[39m: {\n \u001b[32msub\u001b[39m: \u001b[31m1\u001b[39m\n \u001b[32mcid\u001b[39m: CID(\u001b[31mQmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u\u001b[39m)\n \u001b[32mbinary\u001b[39m: Bytes({\u001b[32msize\u001b[39m: \u001b[31m4\u001b[39m})\n \u001b[32marray\u001b[39m: [ \u001b[31m"one"\u001b[39m, \u001b[31m"two"\u001b[39m, \u001b[31m3\u001b[39m ]\n }\n}')
23+
24+
if (supportsColor) {
25+
assert.equal(str, '{\n \u001b[32mone\u001b[39m: \u001b[31m1\u001b[39m\n \u001b[32mtwo\u001b[39m: \u001b[31m"two"\u001b[39m\n \u001b[32mthree\u001b[39m: {\n \u001b[32msub\u001b[39m: \u001b[31m1\u001b[39m\n \u001b[32mcid\u001b[39m: CID(\u001b[31mQmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u\u001b[39m)\n \u001b[32mbinary\u001b[39m: Bytes({\u001b[32msize\u001b[39m: \u001b[31m4\u001b[39m})\n \u001b[32marray\u001b[39m: [ \u001b[31m"one"\u001b[39m, \u001b[31m"two"\u001b[39m, \u001b[31m3\u001b[39m ]\n }\n}')
26+
} else {
27+
assert.equal(str, '{\n one: 1\n two: "two"\n three: {\n sub: 1\n cid: CID(QmWATWQ7fVPP2EFGu71UkfnqhYXDYH566qy47CnJDgvs8u)\n binary: Bytes({size: 4})\n array: [ "one", "two", 3 ]\n }\n}')
28+
}
2329
})

0 commit comments

Comments
 (0)