BREAKING CHANGE(core): major architectural refactoring with fetch-like API
Some checks failed
Default (tags) / security (push) Failing after 24s
Default (tags) / test (push) Failing after 13s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped

This commit is contained in:
2025-07-27 21:23:20 +00:00
parent f7d2c6de4f
commit bbb57004d9
24 changed files with 1038 additions and 593 deletions

View File

@@ -7,7 +7,11 @@ tap.test('modern: should request a html document over https', async () => {
.url('https://encrypted.google.com/')
.get();
expect(response).toHaveProperty('body');
expect(response).not.toBeNull();
expect(response).toHaveProperty('status');
expect(response.status).toBeGreaterThan(0);
const text = await response.text();
expect(text.length).toBeGreaterThan(0);
});
tap.test('modern: should request a JSON document over https', async () => {
@@ -15,8 +19,9 @@ tap.test('modern: should request a JSON document over https', async () => {
.url('https://jsonplaceholder.typicode.com/posts/1')
.get();
expect(response.body).toHaveProperty('id');
expect(response.body.id).toEqual(1);
const body = await response.json();
expect(body).toHaveProperty('id');
expect(body.id).toEqual(1);
});
tap.test('modern: should post a JSON document over http', async () => {
@@ -26,9 +31,10 @@ tap.test('modern: should post a JSON document over http', async () => {
.json(testData)
.post();
expect(response.body).toHaveProperty('json');
expect(response.body.json).toHaveProperty('text');
expect(response.body.json.text).toEqual('example_text');
const body = await response.json();
expect(body).toHaveProperty('json');
expect(body.json).toHaveProperty('text');
expect(body.json.text).toEqual('example_text');
});
tap.test('modern: should set headers correctly', async () => {
@@ -40,12 +46,12 @@ tap.test('modern: should set headers correctly', async () => {
.header(customHeader, headerValue)
.get();
expect(response.body).toHaveProperty('headers');
const body = await response.json();
expect(body).toHaveProperty('headers');
// Check if the header exists (case-sensitive)
expect(response.body.headers).toHaveProperty(customHeader);
expect(response.body.headers[customHeader]).toEqual(headerValue);
expect(body.headers).toHaveProperty(customHeader);
expect(body.headers[customHeader]).toEqual(headerValue);
});
tap.test('modern: should handle query parameters', async () => {
@@ -56,11 +62,12 @@ tap.test('modern: should handle query parameters', async () => {
.query(params)
.get();
expect(response.body).toHaveProperty('args');
expect(response.body.args).toHaveProperty('param1');
expect(response.body.args.param1).toEqual('value1');
expect(response.body.args).toHaveProperty('param2');
expect(response.body.args.param2).toEqual('value2');
const body = await response.json();
expect(body).toHaveProperty('args');
expect(body.args).toHaveProperty('param1');
expect(body.args.param1).toEqual('value1');
expect(body.args).toHaveProperty('param2');
expect(body.args.param2).toEqual('value2');
});
tap.test('modern: should handle timeout configuration', async () => {
@@ -70,7 +77,8 @@ tap.test('modern: should handle timeout configuration', async () => {
.timeout(5000);
const response = await client.get();
expect(response).toHaveProperty('body');
expect(response).toHaveProperty('ok');
expect(response.ok).toBeTrue();
});
tap.test('modern: should handle retry configuration', async () => {
@@ -80,7 +88,8 @@ tap.test('modern: should handle retry configuration', async () => {
.retry(1);
const response = await client.get();
expect(response).toHaveProperty('body');
expect(response).toHaveProperty('ok');
expect(response.ok).toBeTrue();
});
tap.start();