README
Test Crud operations using Mocha and Chai
Please follow the instrucrions to set up the application:
Create a test directory inside your root folder.
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 ); }
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.
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
add following code to your package.json file
"scripts": { "test": "mocha --timeout 2000" }
Run 'npm test' to test the application.