These are chat archives for dareid/chakram

15th
Sep 2015
Mek Stittri
@mekdev
Sep 15 2015 05:53
Had a couple of questions when anyone is free
Do we have to call return in the last statement always ?
    it("should return 200 on success", function () {
        return expect(apiResponse).to.have.status(200);
    });
Can we just use it like how mocha treats sync style tests
Can we use standalone chai vs chakram chai
expect = chakram.expect;
expect = require('chai').expect;
Daniel Reid
@dareid
Sep 15 2015 06:34
You need to either return a promise or call done to ensure the test waits for the assertions. As chakram is built around promises typically a promise is returned from an it to make it wait. Methods like wait are also available to simplify this.
The chakram expect object contains all the chai assertions,
So you can easily use the base chai assertions
without requiring another expect object
Mek Stittri
@mekdev
Sep 15 2015 16:15
Got it!
The chakram expect object also addes the below on top of the chai assertions correct ?
http://dareid.github.io/chakram/jsdoc/module-chakram-expectation.html
I carved out some time to do a deep dive into this today. We are heavily utilizing selenium promise manager which wraps around the mocha test object and we just omit the done call entirely
Mek Stittri
@mekdev
Sep 15 2015 16:26
var test = require('selenium-webdriver/testing'),
    chakram = require('chakram'),
    expect = chakram.expect;

test.describe('Test Suite', function() {
...
    test.it('test 1', function() {
        driver.get(url, 5000);
        // Do ui stuff(s)
        driver.findElement(By.css('input#email')).sendKeys('test@abc.com');
        driver.findElement(By.css('button[type="submit"]')).click();
       // Do api stuff
       chakram.get()
       // Do other stuff with api responses
}
Do you forsee any challenges, our tests are very sync like be design and looks and would love to keep it that way
by*
Daniel Reid
@dareid
Sep 15 2015 17:02
Hmm, well I don't know much about the selenium wrapper you are using there. I would assume that is setup to automatically wait for selenium promises, if that is the case, it may not automatically wait for the promises returned by chakram.
Mek Stittri
@mekdev
Sep 15 2015 17:13
Will try it out!
Daniel Reid
@dareid
Sep 15 2015 17:17
thanks for the link
skimming through that it relies on async calls with the test.it, if you do not have a done parameter
so I think to get chakram working with this you will need to have a done callback
out of interest, are you using chakram to verify the backend changes resulting from front end interaction?
Mek Stittri
@mekdev
Sep 15 2015 17:30
yes
actually more, 1) testing API standalone + functional 2) selenium helpers for the backend
which is why I was looking into a WebClient class so the business API calls can be abstracted out
And chakram is the front runner, i looked at supertests, frisby and etc
Mek Stittri
@mekdev
Sep 15 2015 17:45
You are right getting Error: Some expectation promises were not fulfilled before the test finished. Ensure you are waiting for all the expectations to run
this is with the wrapper used and not returning anything
Daniel Reid
@dareid
Sep 15 2015 17:48
Yea from my quick skim it doesn't seem like the wrapper respects returned promises which is a shame
Your tests sound thorough, very nice!
Mek Stittri
@mekdev
Sep 15 2015 17:58
We could potentially submit a pull request in for the selenium project
Daniel Reid
@dareid
Sep 15 2015 18:10
That would be a great addition if you ask me