rpc_ts
Version:
Remote Procedure Calls in TypeScript made simple
43 lines • 1.57 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @license
* Copyright (c) Aiden.ai
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const child_process = require("child_process");
const path = require("path");
describe('rpc_ts', () => {
describe('examples', () => {
// Just invoke the examples
for (const exampleName of ['context', 'server_stream']) {
it(exampleName, async () => {
await run(path.resolve(__dirname, '..', exampleName));
}).timeout(10000);
}
it('the code in the README.md compiles and runs', async () => {
const projectRoot = path.resolve(__dirname, '../../..');
await run(path.resolve(projectRoot, 'readme_code.ts'), path.resolve(__dirname, '../../../tsconfig.doc.json'));
}).timeout(10000);
});
});
async function run(script, tsNodeProject) {
return new Promise((resolve, reject) => {
child_process
.spawn('yarn', ['ts-node', '-r', 'tsconfig-paths/register', script], {
stdio: 'inherit',
env: !tsNodeProject
? undefined
: Object.assign(Object.assign({}, process.env), { TS_NODE_PROJECT: tsNodeProject }),
})
.on('close', code => {
if (code === 0)
resolve();
else
reject(`non-zero exit code ${code}`);
});
});
}
//# sourceMappingURL=examples.test.js.map
;