Hi all,
I use node-red-node-test-helper for unit testing by creating Node.
I try to send credential data into test function.
Below code is my test function
it("error token", (done) => {
const flow = [
{
id: "n1",
type: "node-line-notify",
name: "node-line-notify",
message: "test",
useExternalData: false,
useImageUrl: false,
useImageFile: false,
useSticker: false,
wires: [["n2"]]
},
{ id: "n2", type: "helper" }
];
helper.load(nodeLineNotify, flow, {token: "test"}, () => { <<<<<<---- Add credential at here
const n1 = helper.getNode("n1");
const n2 = helper.getNode("n2");
n1.on("call:error", (err) => {
console.log(n1);
should.equal(err.lastArg.status, 401);
should.equal(err.lastArg.payload, "Invalid access token");
done();
});
n1.receive({ payload: "test" });
});
});
But when I check my creating node "n1", there is not my credential data in node.
NodeLineNotify {
id: 'n1',
type: 'node-line-notify',
z: undefined,
g: undefined,
_closeCallbacks: [],
_inputCallback: [Function (anonymous)],
_inputCallbacks: null,
name: 'node-line-notify',
wires: [ [ 'n2' ] ],
_wireCount: 1,
send: [Function (anonymous)],
_wire: 'n2',
credentials: {}, <<<<<--------- Credential data is empty
accessToken: undefined,
message: 'test',
useExternalData: false,
useImageUrl: false,
imageFullsizeUrl: undefined,
imageThumbnailUrl: undefined,
useImageFile: false,
imageFile: undefined,
useSticker: false,
lineStickerPackageId: undefined,
lineStickerId: undefined,
disabledPushNotification: undefined,
_events: [Object: null prototype] { 'call:error': [Function (anonymous)] },
_eventsCount: 1
}
How to use credential data with node by node-red-node-test-helper function?