-
Notifications
You must be signed in to change notification settings - Fork 14
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
Expect
syntax support?
#20
Comments
Yes. |
I've been trying to wrap some chai-things in expect syntax as a custom assertion for the purposes of use with Serenity-JS but I get an error when I try to do it. Should works fine. export const AllContainsOrgCode = expected => actual => actual.should.eventually.all.have.property('orgCode', expected);
export const AllContainsOrgCodeExpect = expected => actual => expect(actual).to.eventually.all.have.property('orgCode', expected); The first line works fine but the latter line throws an error: |
@weijie-tang I'm assuming by // Works
chai.use(chaiThings);
chai.use(chaiAsPromised);
it("blah", function () {
var orgs = Promise.resolve([
{"orgCode": 42},
{"orgCode": 42},
]);
return expect(orgs).to.eventually.all.have.property("orgCode", 42);
}); // Doesn't work because of `.use` order
chai.use(chaiAsPromised);
chai.use(chaiThings);
it("blah", function () {
var orgs = Promise.resolve([
{"orgCode": 42},
{"orgCode": 42},
]);
return expect(orgs).to.eventually.all.have.property("orgCode", 42);
}); If that's not the issue, then my second guess is related to a conflict between |
@meeber I have them imported in the same order as you do and I still get the error.
|
@weijie-tang Then my best guess is a conflict between chai-as-promised TypeScript type definitions and chai-things. I base that on the error message you're receiving and the fact that my simple example above works with chai-as-promised and chai-things but no TypeScript. |
Any progress on this? |
I think this now is a general problem as chai now also has |
Hey, When attempting to use expect alongside chai-things it breaks, stating that: expected { Object (sql, values) } to have a property 'length' Order of use is the following: var chai = require('chai'); chai.should(); chai.use(require('chai-things')); var expect = chai.expect; Any hints ? |
@jorgemachado89 Please also add the code for your assertion. It seems logical that an object |
Thanks for the quick feedback. Here follows an example below: var chai = require('chai');
chai.should();
chai.use(require('chai-things'));
var expect = chai.expect;
describe('something', function() {
it('the test description', function() {
expect({
sql: 'sasasasa',
values: [['sasa','sasa'],['sasa','sasasa']]
})
.to.be.an('object')
.to.have.deep.all.keys('sql', 'values');
}};
}); Returns the following: AssertionError: expected { Object (sql, values) } to have a property 'length' Including chai-things, breaks the behaviour of expect from chai |
@RubenVerborgh any progress on this? We've just encountered this as well:
|
@RubenVerborgh I have not been involved anymore with chai for several years, so I unfortunately cannot advise you on this one. |
Could this be solved by replacing the |
Tried several ways, but chai-things do not work in typescript:
Same result
|
Hi!
Does it work with
expect
syntax?The text was updated successfully, but these errors were encountered: