As the title mentioned. I would like to ask that how could i write the test code for this scenario?
Example... i have a class look like this.
let ABC = function()
{
this.title="sample"
};
Question is how do i use chai expect to check for the existences of ABC class?
Does expect chai do something like this? Expect(ABC).to.be.a.class
I'm not sure if you had this answered yet but I had the same question and I just found out
so after requiring chai and the expect API
and after requiring the file where your class resides and setting up your test
you can ensure that:
.to.be.a('function');
expect(className).to.be.an.instance.of(ClassName);
const expect = chai.expect; const Card = require('../src/Card'); describe('Card', function() { it.skip('should be a function', function() { const card = new Card(); expect(Card).to.be.a('function'); }); it.skip('should be an instance of Card', function() { const card = new Card(); expect(card).to.be.an.instanceof(Card); });```
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.