question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Erroneous assertion not breaking the Scenario

See original GitHub issue

What are you trying to achieve?

I’m trying to do an assertion in a test Scenario with 2 values taken from two different pages on a website

What do you get instead?

Even forcing the assertion to fail, test keeps outputting that it PASSED.

A snippet of the assertion part:

        let assert = require('assert');
        I.say('Assertion...');
        assert.true(value1 == (value2 + value3));

I need like a I.assertThat(expression) in order for the test to fail when values don’t match. Right now I’m researching about assertions on codecept and trying to figure out a solution for that.

Details

  • CodeceptJS version: 1.1.1
  • NodeJS Version: 9.4.0
  • Operating System: Linux Mint
  • WebDriverIO

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
reubenmillercommented, Jan 18, 2018

I looked at the package.json and found no dependency to ‘assert’, so they must be using the node assert library. https://nodejs.org/api/assert.html

As per the node js docs, there is no .true property, so unless you’re using another assert library (or I’m reading the docs wrong).

Though I’ve been using the chai (http://chaijs.com/api/bdd/) expect/should module in my project with success. Here’s an example.

const { expect } = require('chai');
expect(true).to.be.true;
1reaction
reubenmillercommented, Jan 19, 2018

I would suggest looking at the source code for the Helpers i.e. in ./lib/helper/WebDriverIO.js. They provide great examples on how to do it.

i.e. this is from the WebDriverIO.js Helper

  async seeInTitle(text) {
    const title = await this.browser.getTitle();
    return stringIncludes('web page title').assert(text, title);
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Erroneous assertion not breaking the Scenario #884 - GitHub
What are you trying to achieve? I'm trying to do an assertion in a test Scenario with 2 values taken from two different...
Read more >
How to continue execution when Assertion is failed
You can declare an assertion that tests both things, but then you're testing two things at once. Better to fix the cause of...
Read more >
How do asserts and other error avoidance checks fit into TDD?
It looks to me like you're experiencing cognitive dissonance, trying to believe two contradictory ideas and accept both as valid.
Read more >
Programming With Assertions - Oracle Help Center
Each assertion contains a boolean expression that you believe will be true when the assertion executes. If it is not true, the system...
Read more >
More Assertions
The one constraint is that assertions that generate a fatal failure ( FAIL* and ASSERT_* ) can only be used in void-returning functions....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found