skip to Main Content

I have a .testcaferc.js as below

module.exports = {
    userVariables: {
        stress_test_num_rep: 200,
    }
}

and some simple code to test it

import { Selector, t } from 'testcafe';
import { setTimeout } from "timers/promises";
const { userVariables } = require('testcafe');
const num_rep = userVariables.stress_test_run_rep;

I set a breakpoint below this code block, the userVariables is correct, it’s { stress_test_num_rep: 200, } but num_rep is undefined

However, what’s more interesting is if I evaluate userVariables.stress_test_run_rep several times in debug console (VSCode), it’s value will appear.

I want to get this num_rep, how could I do it? From the official example this should not be an async method, shouldn’t it?

2

Answers


  1. import { Selector, t } from 'testcafe';
    import { setTimeout } from "timers/promises";
    const { userVariables } = require('testcafe');
    const num_rep = userVariables.stress_test_run_rep;
    console.log(num_rep); // Now it will print 200
    
    Login or Signup to reply.
  2. There’s a spelling mistake. ‘userVariables’ has a ‘stress_test_num_rep’ property, but you try to get the ‘stress_test_run_rep’ property.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search