3

I'm trying to build some tests for my bot dialogs. I'm using the same test code (and modified test data) with two different bots with the identical dialog names. As such, the test.js file is the same for both bots. However, when I try to run my tests via Mocha on the second bot, I am getting an Error: DialogSet.add(): Invalid dialog being added. message for each test. This does not happen with my first bot. I even tried replacing the dialog file in the second bot with the one from the (working) first, and I still got the same error. As such I can't find anything different between the bots. I even replaced all of the files in question (the test, the test data/conversation, and the dialog itself) with the files from the first bot and still got the same error. Lastly, all botbuilder packages and other dependencies are the same version between the bots. I'm at a loss here...anyone have any ideas?

Here is the dialog that is being called. I left out the actual dialog steps but that shouldn't be relevant to the issue since all of the Dialog add activity happens in the constructor.

const { TextPrompt, ChoicePrompt, ConfirmPrompt, ChoiceFactory, ComponentDialog, WaterfallDialog, DialogSet, DialogTurnStatus } = require('botbuilder-dialogs');
const { VistaServiceHelper } = require('../helpers/vistaServiceHelper');
const { TrackingServiceHelper } = require('../helpers/trackingServiceHelper');
const { CosmosDbStorage } = require('botbuilder-azure');

const LINE_PROMPT = 'linePrompt';
const ORDER_PROMPT = 'orderPrompt';
const CRITERIA_PROMPT = 'criteriaPrompt';
const SEARCH_CRITERIA = ['GO', 'PO'];
const WATERFALL_DIALOG = 'waterfallDialog';
const CONFIRM_PROMPT = 'confirmPrompt';

// Static texts
const escalateMessage = `Escalation message here`

const msDay = 86400000;

class viewOrderDialog extends ComponentDialog {
    constructor(dialogId, userDialogStateAccessor, userState) {
        super(dialogId);

        this.addDialog(new ChoicePrompt(CRITERIA_PROMPT));
        this.addDialog(new TextPrompt(ORDER_PROMPT));
        this.addDialog(new TextPrompt(LINE_PROMPT, this.validateLineNumber));
        this.addDialog(new ConfirmPrompt(CONFIRM_PROMPT));
        this.addDialog(new WaterfallDialog(WATERFALL_DIALOG, [
            this.requestOrderNumber.bind(this),
            this.selectSearchCriteria.bind(this),
            this.displayLineItems.bind(this),
            this.displayLineStatus.bind(this),
            this.loopStep.bind(this)
        ]));

        this.initialDialogId = WATERFALL_DIALOG;

        this.integrationLog = new CosmosDbStorage({
            serviceEndpoint: process.env.ACTUAL_SERVICE_ENDPOINT,
            authKey: process.env.ACTUAL_AUTH_KEY,
            databaseId: process.env.DATABASE,
            collectionId: 'integration-logs'
        });

        this.queryData = {};

    } // End constructor
4
  • Not sure why it would work in one and not the other. Can you share the dialog? That error gets thrown if your dialog isn't an instance of Dialog. Might also need your DialogTestClient, so I can see how it's getting passed around. If you can link to the repo, that might be easier. Oct 18, 2019 at 17:10
  • I saw that in the code but I couldn't figure out why I was having an issue in just that one bot. One of my colleagues said he got the same error and fixed it by updating all the botbuilder packages to latest, but I checked and all of them, including the botbuilder-dialogs inside botbuilder-testing, are 4.5.3. I just tried to invite you to the repo. Oct 18, 2019 at 17:40
  • I don't seem to have gotten an invite. You tried my github account? Oct 18, 2019 at 18:22
  • Added the dialog constructor to the original question. Oct 18, 2019 at 18:23

3 Answers 3

5

I was able to fix this by deleting the botbuilder-testing folder inside the project's node_modules folder and rerunning npm install botbuilder-testing (even though I had already confirmed version in package.json and package-lock.json were showing latest version and had run npm install and npm update).

It appears this did stem from some sort of versioning issue and for whatever reason, only completely deleting the folder and reinstalling fixed it.

1

You may want to also verify the version of botbuilder inside your package.json file, because all of this packages must be at the same version

Ex:

"botbuilder": "~4.10.3",
"botbuilder-ai": "~4.10.3",
"botbuilder-dialogs": "~4.10.3",
"botbuilder-testing": "~4.10.3",
0

I Believe the accepted answer does not work in all cases . the correct answer would be to have the same botbuilder and botbuilder-testing versions . I had the same problem and putting the same versions (or at least not putting a botbuilder-testing version above botbuilder worked) Example Here are example versions that work together :

 "botbuilder": "~4.13.6",
 "botbuilder-dialogs": "~4.13.6",
 "botbuilder-testing": "^4.13.6",
3
  • Link-only responses are fine as a Comment, but are unacceptable as answers. Answers must be self contained, and exact code necessary to solve the issue must be embedded. Links are perfectly acceptable, BUT relevant info from the link must be embedded. No-one wants to click on blind links, and, importantly, your response becomes useless if the site becomes unreachable, or the content changes.
    – Tyler2P
    Aug 13, 2021 at 12:07
  • I understand, i modified my answer to include example code .
    – Khorf
    Aug 13, 2021 at 12:22
  • I don't disagree that the accepted solution may not work in all cases, but I had found the "all need to be the same version" solution before and made sure all my packages were the same version and it still didn't work. It wasn't until I removed and reinstalled the package that it started working again. Aug 13, 2021 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.