Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert() api ref is not accurate #1162

Closed
CutOffFrequency opened this issue May 18, 2018 · 1 comment
Closed

assert() api ref is not accurate #1162

CutOffFrequency opened this issue May 18, 2018 · 1 comment

Comments

@CutOffFrequency
Copy link

CutOffFrequency commented May 18, 2018

according to the api ref...

assert(expression, message)
@param { Mixed } expression to test for truthiness
@param { String } message to display on error
Write your own test expressions.

assert('foo' !== 'bar', 'foo is not bar');
assert(Array.isArray([]), 'empty arrays are arrays');

however...

describe('assert', () => {
it('swallows the second argument silently', () => {
assert(true,'this string will be swallowed silently and will not be displayed in terminal')
})
})

// assert
// (passes) swallows the second argument silently

and I could not run assert() by itself ie in a describe block outside of it() or some equivalence

@meeber
Copy link
Contributor

meeber commented May 19, 2018

@HumanSprout Custom messages are only displayed if the assertion fails.

const {assert, expect} = require("chai");

describe('assert', () => {
  it('passing assertion', () => {
    assert(true, 'this string is never displayed because assertion passes')
  })
  it('failing assertion', () => {
    assert(false, 'this string is displayed because assertion fails')
  })
})

assert
✓ passing assertion
1) failing assertion

1 passing (9ms)
1 failing

  1. assert
    failing assertion:
    AssertionError: this string is displayed because assertion fails
    at Context.it (test/index.js:8:5)

@CutOffFrequency CutOffFrequency changed the title assert() api ref is not accurate ref api May 19, 2018
@CutOffFrequency CutOffFrequency changed the title ref api A ZEN STORY May 19, 2018
@chaijs chaijs locked as spam and limited conversation to collaborators May 20, 2018
@keithamus keithamus changed the title A ZEN STORY assert() api ref is not accurate May 20, 2018
@meeber meeber closed this as completed May 21, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants