forked from extern/bruno
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
|
const { describe, it, expect } = require('@jest/globals');
|
||
|
const TestRuntime = require('../src/runtime/test-runtime');
|
||
|
|
||
|
describe('runtime', () => {
|
||
|
describe('test-runtime', () => {
|
||
|
const baseRequest = {
|
||
|
method: 'GET',
|
||
|
url: 'http://localhost:3000/',
|
||
|
headers: {},
|
||
|
data: undefined
|
||
|
};
|
||
|
const baseResponse = {
|
||
|
status: 200,
|
||
|
statusText: 'OK',
|
||
|
data: [
|
||
|
{
|
||
|
id: 1
|
||
|
},
|
||
|
{
|
||
|
id: 2
|
||
|
},
|
||
|
{
|
||
|
id: 3
|
||
|
}
|
||
|
]
|
||
|
};
|
||
|
|
||
|
it('should wait async tests', async () => {
|
||
|
const testFile = `
|
||
|
await test('async test', ()=> {
|
||
|
return new Promise((resolve)=> {
|
||
|
setTimeout(()=> {resolve()},200)
|
||
|
})
|
||
|
})
|
||
|
`;
|
||
|
|
||
|
const runtime = new TestRuntime();
|
||
|
const result = await runtime.runTests(
|
||
|
testFile,
|
||
|
{ ...baseRequest },
|
||
|
{ ...baseResponse },
|
||
|
{},
|
||
|
{},
|
||
|
'.',
|
||
|
null,
|
||
|
process.env
|
||
|
);
|
||
|
expect(result.results.map((el) => ({ description: el.description, status: el.status }))).toEqual([
|
||
|
{ description: 'async test', status: 'pass' }
|
||
|
]);
|
||
|
});
|
||
|
});
|
||
|
});
|