Cannot integrate third party tools with TectCafe Studio

118 Views Asked by At

I'm new to TestCafe and TypeScript.

I was trying to integrate the NanoID module to TestCafe following this tutorial. But it shows an error saying Cannot find module 'nanoid' or its corresponding type declarations. (2307).

But when I tried with uuid, it worked for the following code.

var uuid = require("uuid");
var id = uuid.v4();

How can I fix this or can you recommend me another module like faker.js?
(I want to generate random data for testing purposes)

2

There are 2 best solutions below

1
On

The official documentation is incomplete , without showing where the module should stay. https://docs.devexpress.com/TestCafeStudio/401265/test-actions/custom-scripts#import-third-party-modules

Like they said , "The modules should be installed in the test directory." but if you do this using NPM INSTALL is still not working. I do not belive that there is a way to add node modules to TestCafe Studio until now.

0
On

Faker would be the best fake data generator. First you need to add the faker library into your testing directory. Then just add a custom script and get any data you need by calling the data.

const { faker } = require('@faker-js/faker');
const first_name = Selector('#first_name');
await t
    .typeText(first_name,faker.name.firstName());