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

Not working with chai-as-promised #9

rickwargo opened this Issue Jan 4, 2016 · 3 comments


None yet
2 participants

rickwargo commented Jan 4, 2016

I am unable to get the following code to work with chai-as-promised.

describe('the complete help intent', function () {
    it('should respond with the complete help message', function () {
        var result = request.intentRequest({ name: 'CompleteHelpIntent' });
        return result.should.eventually.startWith('<speak>' + Text.helpMessage);

The above code responds with the following, I believe because the str parameter in chai.string.startsWith is a Promise and not a string.

TypeError: undefined is not a function
    at Object.chai.string.startsWith (/Users/rick/Code/Alexa/alexa-app/node_modules/chai-string/chai-string.js:23:16)
    at startsWithMethodWrapper (/Users/rick/Code/Alexa/alexa-app/node_modules/chai-string/chai-string.js:81:19)
    at assert (node_modules/chai/lib/chai/utils/addChainableMethod.js:83:49)
    at Context.<anonymous> (test/intents.js:57:41)

I need to revert to an async pattern for the test to be successful.

describe('the help intent', function () {
    it('should respond with the help message', function () {
        return request.intentRequest({ name: 'AMAZON.HelpIntent' })
            .then(function (result) {
                result.should.startWith('<speak>' + Text.helpMessage);

@onechiporenko onechiporenko self-assigned this Jan 4, 2016

@onechiporenko onechiporenko added bug and removed bug labels Jan 4, 2016


This comment has been minimized.

rickwargo commented Jan 4, 2016

Thank you! Indeed the order is significant with .use(). The following code resolved the issue:

var chai = require('chai'),
    chaiAsPromised = require('chai-as-promised'),
    chaiString = require('chai-string'),
    should = require('chai').should();


@rickwargo rickwargo closed this Jan 4, 2016


This comment has been minimized.

rickwargo commented Mar 27, 2017

After adding more test files, it took me quite a while to realize that order is important across the files. Ensure the first test file mocha executes has the order correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment