test: skip tests for Electron / Android (#16731)

This commit is contained in:
Max Schmitt 2022-08-22 22:20:45 +02:00 коммит произвёл GitHub
Родитель e344fe60e7
Коммит 26df4cc00e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 60 добавлений и 54 удалений

Просмотреть файл

@ -300,66 +300,72 @@ test('should print selector syntax error', async ({ page }) => {
expect(error.message).toContain(`Unexpected token "]" while parsing selector "row]"`);
});
test('toBeOK', async ({ page, server }) => {
const res = await page.request.get(server.EMPTY_PAGE);
await expect(res).toBeOK();
});
test.describe(() => {
test.skip(({ isAndroid }) => isAndroid, 'server.EMPTY_PAGE is the emulator address 10.0.2.2');
test.skip(({ isElectron }) => isElectron, 'Protocol error (Storage.getCookies): Browser context management is not supported.');
test('not.toBeOK', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/unknown`);
await expect(res).not.toBeOK();
});
test('toBeOK', async ({ page, server }) => {
const res = await page.request.get(server.EMPTY_PAGE);
await expect(res).toBeOK();
});
test('toBeOK fail with invalid argument', async ({ page }) => {
const error = await (expect(page) as any).toBeOK().catch(e => e);
expect(error.message).toContain('toBeOK can be only used with APIResponse object');
});
test('not.toBeOK', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/unknown`);
await expect(res).not.toBeOK();
});
test('toBeOK fail with promise', async ({ page, server }) => {
const res = page.request.get(server.EMPTY_PAGE).catch(e => {});
const error = await (expect(res) as any).toBeOK().catch(e => e);
expect(error.message).toContain('toBeOK can be only used with APIResponse object');
});
test.describe('toBeOK should print response with text content type when fails', () => {
test.beforeEach(async ({ server }) => {
server.setRoute('/text-content-type', (req, res) => {
res.statusCode = 404;
res.setHeader('Content-type', 'text/plain');
res.end('Text error');
test('toBeOK fail with invalid argument', async ({ page }) => {
const error = await (expect(page) as any).toBeOK().catch(e => e);
expect(error.message).toContain('toBeOK can be only used with APIResponse object');
});
test('toBeOK fail with promise', async ({ page, server }) => {
const res = page.request.get(server.EMPTY_PAGE).catch(e => {});
const error = await (expect(res) as any).toBeOK().catch(e => e);
expect(error.message).toContain('toBeOK can be only used with APIResponse object');
});
test.describe('toBeOK should print response with text content type when fails', () => {
test.beforeEach(async ({ server }) => {
server.setRoute('/text-content-type', (req, res) => {
res.statusCode = 404;
res.setHeader('Content-type', 'text/plain');
res.end('Text error');
});
server.setRoute('/no-content-type', (req, res) => {
res.statusCode = 404;
res.end('No content type error');
});
server.setRoute('/binary-content-type', (req, res) => {
res.statusCode = 404;
res.setHeader('Content-type', 'image/bmp');
res.end('Image content type error');
});
});
server.setRoute('/no-content-type', (req, res) => {
res.statusCode = 404;
res.end('No content type error');
test('text content type', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/text-content-type`);
const error = await expect(res).toBeOK().catch(e => e);
expect(error.message).toContain(`→ GET ${server.PREFIX}/text-content-type`);
expect(error.message).toContain(`← 404 Not Found`);
expect(error.message).toContain(`Text error`);
});
server.setRoute('/binary-content-type', (req, res) => {
res.statusCode = 404;
res.setHeader('Content-type', 'image/bmp');
res.end('Image content type error');
test('no content type', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/no-content-type`);
const error = await expect(res).toBeOK().catch(e => e);
expect(error.message).toContain(`→ GET ${server.PREFIX}/no-content-type`);
expect(error.message).toContain(`← 404 Not Found`);
expect(error.message).not.toContain(`No content type error`);
});
test('image content type', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/image-content-type`);
const error = await expect(res).toBeOK().catch(e => e);
expect(error.message).toContain(`→ GET ${server.PREFIX}/image-content-type`);
expect(error.message).toContain(`← 404 Not Found`);
expect(error.message).not.toContain(`Image content type error`);
});
});
test('text content type', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/text-content-type`);
const error = await expect(res).toBeOK().catch(e => e);
expect(error.message).toContain(`→ GET ${server.PREFIX}/text-content-type`);
expect(error.message).toContain(`← 404 Not Found`);
expect(error.message).toContain(`Text error`);
});
test('no content type', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/no-content-type`);
const error = await expect(res).toBeOK().catch(e => e);
expect(error.message).toContain(`→ GET ${server.PREFIX}/no-content-type`);
expect(error.message).toContain(`← 404 Not Found`);
expect(error.message).not.toContain(`No content type error`);
});
test('image content type', async ({ page, server }) => {
const res = await page.request.get(`${server.PREFIX}/image-content-type`);
const error = await expect(res).toBeOK().catch(e => e);
expect(error.message).toContain(`→ GET ${server.PREFIX}/image-content-type`);
expect(error.message).toContain(`← 404 Not Found`);
expect(error.message).not.toContain(`Image content type error`);
});
});