diff --git a/lib/assert.js b/lib/assert.js index 15818739c..a55a06721 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -27,7 +27,7 @@ function formatWithLabel(label, value) { return formatDescriptorWithLabel(label, concordance.describe(value, concordanceOptions)); } -const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop); +export const hasOwnProperty = (object, prop) => Object.prototype.hasOwnProperty.call(object, prop); const noop = () => {}; const notImplemented = () => { throw new Error('not implemented'); diff --git a/lib/test.js b/lib/test.js index 816b7dda2..6f7827bb2 100644 --- a/lib/test.js +++ b/lib/test.js @@ -2,7 +2,7 @@ import concordance from 'concordance'; import isPromise from 'is-promise'; import plur from 'plur'; -import {AssertionError, Assertions, checkAssertionMessage} from './assert.js'; +import {AssertionError, Assertions, checkAssertionMessage, hasOwnProperty} from './assert.js'; import concordanceOptions from './concordance-options.js'; import nowAndTimers from './now-and-timers.cjs'; import parseTestArgs from './parse-test-args.js'; @@ -14,7 +14,7 @@ function isExternalAssertError(error) { } // Match errors thrown by and . - return error.hasOwnProperty('actual') && error.hasOwnProperty('expected'); + return hasOwnProperty(error, 'actual') && hasOwnProperty(error, 'expected'); } function formatErrorValue(label, error) { @@ -533,13 +533,13 @@ export default class Test { this.saveFirstError(new AssertionError({ message: 'Assertion failed', savedError: result.error instanceof Error && result.error, - values: [{label: 'Assertion failed: ', formatted: result.error.message}] + values: [{label: 'Assertion failed: ', formatted: result.error.message}], })); } else { this.saveFirstError(new AssertionError({ message: 'Error thrown in test', savedError: result.error instanceof Error && result.error, - values: [formatErrorValue('Error thrown in test:', result.error)] + values: [formatErrorValue('Error thrown in test:', result.error)], })); } @@ -586,13 +586,13 @@ export default class Test { this.saveFirstError(new AssertionError({ message: 'Assertion failed', savedError: error instanceof Error && error, - values: [{label: 'Assertion failed: ', formatted: error.message}] + values: [{label: 'Assertion failed: ', formatted: error.message}], })); } else { this.saveFirstError(new AssertionError({ message: 'Rejected promise returned by test', savedError: error instanceof Error && error, - values: [formatErrorValue('Rejected promise returned by test. Reason:', error)] + values: [formatErrorValue('Rejected promise returned by test. Reason:', error)], })); } }) diff --git a/test/external-assertions/fixtures/expect-failure.js b/test/external-assertions/fixtures/expect-failure.js index 2825f9cad..b410bc858 100644 --- a/test/external-assertions/fixtures/expect-failure.js +++ b/test/external-assertions/fixtures/expect-failure.js @@ -1,6 +1,5 @@ -import { expect } from 'expect'; - import test from 'ava'; +import {expect} from 'expect'; test('test', () => { expect(false).toBeTruthy();