I am currently writing a short piece of code for a Zapier integration. The code simply takes an input (provided by Zapier), and generates an output.
I am developing this locally because it is quicker and faster, but I also want to add tests to check that an input produces the right output.
I need to figure out how to require the file into the Mocha test, and then check the output is what it should be:
//index.js
// This is mock data which will be inputted automatically by Zapier
const inputData = {
"data": "My String",
}
// ALL ABOVE THIS LINE IS REMOVED WHEN I COPY OVER TO ZAPIER
let output = {};
let newData = inputData.data;
newData = newData.toLowerCase();
output = {...output, newData};
console.log(output);
// test.js
const assert = require('assert');
const indexFile = require('../index');
describe('Output', () => {
it('should return', () => {
// todo test that string was converted to lower case correctly
})
})
The only thing I can think of, is wrapping the whole file in a function, and adding a return statement, which may be the only way..?
Aucun commentaire:
Enregistrer un commentaire