MCPcopy Index your code
hub / github.com/nodejs/node-addon-api / test

Function test

test/maybe/index.js:13–34  ·  view source on GitHub ↗
(binding)

Source from the content-addressed store, hash-verified

11};
12
13function test (binding) {
14 if (process.argv.includes('child')) {
15 child(binding);
16 return;
17 }
18 const cp = napiChild.spawn(process.execPath, [__filename, 'child'], {
19 stdio: ['ignore', 'inherit', 'pipe']
20 });
21 cp.stderr.setEncoding('utf8');
22 let stderr = '';
23 cp.stderr.on('data', chunk => {
24 stderr += chunk;
25 });
26 cp.on('exit', (code, signal) => {
27 if (process.platform === 'win32') {
28 assert.strictEqual(code, 128 + 6 /* SIGABRT */);
29 } else {
30 assert.strictEqual(signal, 'SIGABRT');
31 }
32 assert.ok(stderr.match(/FATAL ERROR: Napi::Maybe::Check Maybe value is Nothing./));
33 });
34}
35
36function child (binding) {
37 const MAGIC_NUMBER = 12459062;

Callers 2

index.jsFile · 0.70
index.jsFile · 0.50

Calls 1

childFunction · 0.70

Tested by

no test coverage detected