1

I am using minimist to run the same testcafe code for different env like a test, stage, Prod. however when the URL is hit it's saying 500 internal error. If I am hitting the Url without using minimist then it's working fine. Please tell me what am I missing

My code:

import * as minimist from 'minimist';

    fixture('Verifying')
       .beforeEach(async t =>{
        console.log("Execution Started ");
        const args = minimist(process.argv.slice(2));
        var environment = args.env;
        if(environment == 'Test')
        {
            t.ctx.Connectionstring=config.Test.Connectionstring;
            t.ctx.Url=config.Test.Url;
        }
        else if(environment == 'Stage')
        {
            t.ctx.Connectionstring=config.Stage.Connectionstring;
            t.ctx.Url=config.Stage.Url;
        }
        else if(environment == 'Prod')
        {
            t.ctx.Connectionstring=config.Prod.Connectionstring;
            t.ctx.Url=config.Prod.Url;
        }

    My config file:
    const config = {
        "Test":{
            "Url": 'abctest.com',
            "Connectionstring": '....',


    },

    "Stage":{
        "Url": 'abctest.com',
            "Connectionstring": '....',


    },

    "Prod":{
        Url": 'abctest.com',
            "Connectionstring": '....',


    },
    };
    export default  config;
Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
TS0306
  • 177
  • 12
  • 1
    Could you clarify if you use CLI or Programming Interface to run testcafe? There may be more arguments in case if a command line is used. You can try to debug this code (as described here: [Debug Tests](https://devexpress.github.io/testcafe/documentation/recipes/debug-tests/) ) to find out what is the real url that you get. I tried to run your code on my side and it seems that you are importing the CommonJS **minimist** module as ES6. Try to use the following: `const minimist = require('minimist');` – Dmitry Ostashev Aug 22 '19 at 13:58
  • @DmitryOstashev - ok i understood what is the issue, the issue is not with minimist cause if i am giving config.TEST.URL its working fine. the issue is with the test controller , i posted the problem under another title, if possible take a look. Title- "Test controller from Fixture passing to TESTS" – TS0306 Aug 22 '19 at 18:20

0 Answers0