Cannot use 'should' assertion style with mocha / chai / chai-as-promised
See original GitHub issueI tried to use myElement.getText().should.eventually.equal("foo")
as in the chai-as-promised manual, but got TypeError: Cannot read property 'eventually' of undefined
. This is not a problem with chai-as-promised
either, because myElement.getText().should.equal("foo")
failed with a similar error. Using expect
works as expected, though.
var chai = require('chai');
chai.use(require('chai-as-promised'));
var should = chai.should();
describe('Home', function() {
it('should say hello', function() {
browser.get('/');
$('h1').getText().should.eventually.equal('Hello, world');
});
});
Issue Analytics
- State:
- Created 9 years ago
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Chai Assertions for Promises
Chai as Promised extends Chai with a fluent language for asserting facts about ... the existing format of assertions being used on a...
Read more >expecting promised to resolve or reject doesn't properly fail a ...
My suggestion above just to show different style on how to use chai-as-promise, and since ewok asked on how to put several assertions...
Read more >JavaScript — Unit Testing using Mocha and Chai - codeburst
Assertion with Chai provides expressive language & readable style like below test. In below sample test, we put assertion like car.should.have.
Read more >Mocha - the fun, simple, flexible JavaScript test framework
This means you can use libraries such as: should.js - BDD style shown throughout these docs; expect.js - expect() style assertions; chai -...
Read more >How to use the chai.should function in chai - Snyk
'use strict'; /* eslint-disable max-len, no-console, padded-blocks, no-multiple-empty-lines */ /* eslint-env node,mocha */ // These tests make use of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vladei I received a similar error until I confirmed the following as the correct order:
Sweet, closing as fixed.