Hello, I am testing code coverage using your commands - fdk run and fdk test.
But it seems that istanbul js doesn’t see my tests.
An important thing, I took only one function for the example. In real code I have more of them and that’s why code coverage doesn’t pass validation. Below is the code, tests and screenshots.
app/scripts/app.js
let client;
init();
async function init() {
client = await app.initialized();
client.events.on('app.activated', renderOrder);
}
function searchOrderNumber(ticketDescription) {
let regExp = new RegExp(
'(order|order number|Bestellung|Amazon-Bestellung|Bestellnummer|Verwendungszweck)' +
'(\\s*|:\\s*|:\\s*#|:\\s*№)' +
'(([A-Za-z]+\\d+)|(\\d+-?)+|\\d+)'
);
let orderNumber = ticketDescription.match(regExp);
if (orderNumber) {
return orderNumber[3];
}
return null;
}
async function renderOrder() {
const ticket = await client.data.get('ticket');
searchOrderNumber(ticket.ticket['description_text']);
}
module.exports = {
searchOrderNumber,
};
test/server.js
const assert = require('assert');
const ticketDescription = require('../app/test_data/ticketDescription.json');
const app = require('../app/scripts/app.js');
describe('searchOrderNumber', function () {
it('should return order number', function () {
assert.equal(app.searchOrderNumber(ticketDescription['description']), 'AU202308406');
});
it('should return null if order number not found', function () {
assert.equal(app.searchOrderNumber('Some description without order number'), null);
});
});
fdk test
coverage/app.js.html
What else do I need to write in the tests to fix this error? I have a positive and a negative test.
Does instanbul js see my tests?
Thank you for the answers!