1.1.1 • Published 6 years ago
@pramod9255/test-api v1.1.1
Test Crud operations using Mocha and Chai
Please follow the instrucrions to set up the application:
1) Create a test directory inside your root folder. 2) Create index.js file inside test folder and add following code:
const startTest = require('@pramod9255/test-api/test');
var path = require("path");
const Server_File = "server.js"; //server file name
const CSV_FILE = "test-cases.csv"; //csv file name
var csvFilePath, server;
try {
server = require(path.resolve('./'+ Server_File));
} catch (e) {
console.log('Please add server file.')
}
try {
csvFilePath = path.resolve("./"+ CSV_FILE);
} catch (e) {
console.log('Please add csv file')
}
if(server && csvFilePath){
startTest(csvFilePath, server );
}
3) Add your test-cases in csv file (ex: test-cases.csv).
N.B. : Please check 'node_modules/@pramod9255/test-api/sample-test-cases.csv' file for the csv file format.
4) To use this application, you need to install mocha and chai. Please use the bellow commands to install the same:
npm install -g mocha --save
npm install chai --save
5) add following code to your package.json file
"scripts": {
"test": "mocha --timeout 2000"
}
6) Run 'npm test' to test the application.