test: minor improvements to the Node spec

- reformat some parts
 - better failures reporting with `expect`
 - skip some tests instead of marking them as passed
This commit is contained in:
Aleksei Kuzmin 2018-09-19 12:54:58 +02:00
parent 4e679a3f28
commit ae95f77d68

View file

@ -1,5 +1,6 @@
const assert = require('assert') const assert = require('assert')
const ChildProcess = require('child_process') const ChildProcess = require('child_process')
const { expect } = require('chai')
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const os = require('os') const os = require('os')
@ -206,10 +207,10 @@ describe('node feature', () => {
}) })
describe('inspector', () => { describe('inspector', () => {
let child let child = null
afterEach(() => { afterEach(() => {
if (child != null) child.kill() if (child !== null) child.kill()
}) })
it('supports starting the v8 inspector with --inspect/--inspect-brk', (done) => { it('supports starting the v8 inspector with --inspect/--inspect-brk', (done) => {
@ -356,8 +357,7 @@ describe('node feature', () => {
it('should have isTTY defined on Mac and Linux', function () { it('should have isTTY defined on Mac and Linux', function () {
if (isCI || process.platform === 'win32') { if (isCI || process.platform === 'win32') {
// FIXME(alexeykuzmin): Skip the test. this.skip()
// this.skip()
return return
} }
@ -366,8 +366,7 @@ describe('node feature', () => {
it('should have isTTY undefined on Windows', function () { it('should have isTTY undefined on Windows', function () {
if (isCI || process.platform !== 'win32') { if (isCI || process.platform !== 'win32') {
// FIXME(alexeykuzmin): Skip the test. this.skip()
// this.skip()
return return
} }
@ -393,17 +392,23 @@ describe('node feature', () => {
}) })
}) })
describe('vm.createContext', () => { describe('vm.runInNewContext', () => {
it('should not crash', () => { it('should not crash', () => {
require('vm').runInNewContext('') require('vm').runInNewContext('')
}) })
}) })
it('includes the electron version in process.versions', () => { it('includes the electron version in process.versions', () => {
assert(/^\d+\.\d+\.\d+(\S*)?$/.test(process.versions.electron)) expect(process.versions)
.to.have.own.property('electron')
.that.is.a('string')
.and.matches(/^\d+\.\d+\.\d+(\S*)?$/)
}) })
it('includes the chrome version in process.versions', () => { it('includes the chrome version in process.versions', () => {
assert(/^\d+\.\d+\.\d+\.\d+$/.test(process.versions.chrome)) expect(process.versions)
.to.have.own.property('chrome')
.that.is.a('string')
.and.matches(/^\d+\.\d+\.\d+\.\d+$/)
}) })
}) })