How to use toBeEmpty method in Playwright Internal

Best JavaScript code snippet using playwright-internal

iterable.test.js

Source:iterable.test.js Github

copy

Full Screen

1'use strict';2const iterable = require('../dist/iterable');3expect.extend({4 toBeEmpty(received) {5 for (const item in received) {6 return {7 message: () => `${received} is iterable, but it is not empty. First value: ${item}`,8 pass: false9 };10 }11 return {12 pass: true13 };14 },15 toYield(received, expectedValues, elementsEqual) {16 if (elementsEqual === undefined) {17 elementsEqual = (a, b) => a === b;18 }19 const actual = Array.from(received);20 if (actual.length > expectedValues.length) {21 return {22 message: () => `${actual} has more elements (${actual.length}) than ${expectedValues} (${expectedValues.length})`,23 pass: false24 };25 } else if (actual.length < expectedValues.length) {26 return {27 message: () => `${actual} has fewer elements (${actual.length}) than ${expectedValues} (${expectedValues.length})`,28 pass: false29 };30 }31 // `actual` and `expectedValues` have the same length32 for (let i = 0; i < actual.length; i++) {33 if (!elementsEqual(actual[i], expectedValues[i])) {34 return {35 message: () => `${actual} and ${expectedValues} differ at index ${i} (${actual[i]} != ${expectedValues[i]})`,36 pass: false37 };38 }39 }40 return {41 pass: true42 };43 }44});45function pairsStrictEqual(lhs, rhs) {46 return lhs[0] === rhs[0]47 && lhs[1] === rhs[1];48}49describe('iterable.isIterable', () => {50 function* generatorFunction() {51 yield true;52 }53 const areIterable = [54 [],55 [0],56 [0, 1, 2],57 'hello',58 generatorFunction()59 ];60 test.each(areIterable)('is true for %p', (obj) => {61 expect(iterable.isIterable(obj)).toBe(true);62 });63 const notIterable = [64 1,65 { a: 1 },66 generatorFunction67 ];68 test.each(notIterable)('is false for %p', (obj) => {69 expect(iterable.isIterable(obj)).toBe(false);70 });71});72describe('iterable.concat', () => {73 test('returns an empty iterable when nothing is chained', () => {74 expect(iterable.concat()).toBeEmpty();75 });76 test('passes through a single argument', () => {77 expect(iterable.concat([1, 2])).toYield([1, 2]);78 });79 test('joins multiple arguments', () => {80 expect(iterable.concat([1, 2], (function* () { yield 3; yield 4; })(), [5])).toYield([1, 2, 3, 4, 5]);81 });82});83describe('iterable.range', () => {84 test('returns an empty iterable for an empty range', () => {85 expect(iterable.range(1, 0)).toBeEmpty();86 expect(iterable.range(0, 0)).toBeEmpty();87 expect(iterable.range(0, 0, 4)).toBeEmpty();88 });89 test('returns a range for integer bounds', () => {90 expect(iterable.range(0, 1)).toYield([0]);91 expect(iterable.range(0, 5)).toYield([0, 1, 2, 3, 4]);92 expect(iterable.range(3, 6)).toYield([3, 4, 5]);93 expect(iterable.range(-2, 0)).toYield([-2, -1]);94 });95 test('returns a range with a step size for integer bounds', () => {96 expect(iterable.range(0, 1, 3)).toYield([0]);97 expect(iterable.range(0, 5, 1)).toYield([0, 1, 2, 3, 4]);98 expect(iterable.range(3, 6, 2)).toYield([3, 5]);99 });100 test('rejects a nonpositive step size', () => {101 expect(() => [...iterable.range(0, 1, -1)]).toThrow(RangeError);102 expect(() => [...iterable.range(0, 5, 0)]).toThrow(RangeError);103 });104 test('returns a range for floating-point bounds', () => {105 // Checking equality with floats is bad, but using literals and adding integers should be predictable.106 // If this becomes flaky, pass an approximate equality function to `toYield`.107 expect(iterable.range(0.5, 3.6)).toYield([0.5, 1.5, 2.5, 3.5]);108 });109});110describe('iterable.enumerate', () => {111 test('returns an empty iterable when passed an empty iterable', () => {112 expect(iterable.enumerate([])).toBeEmpty();113 });114 test('enumerates a nonempty iterable', () => {115 expect(iterable.enumerate(['a', 'b', 'c'])).toYield([116 [0, 'a'], [1, 'b'], [2, 'c']117 ], pairsStrictEqual);118 });119});120describe('iterable.map', () => {121 test('returns an empty iterable when passed an empty iterable', () => {122 expect(iterable.map([], x => x)).toBeEmpty();123 });124 test('invokes a function on a nonempty iterable', () => {125 expect(iterable.map([1, 2, 3], x => 2 * x)).toYield([2, 4, 6]);126 });127});128describe('iterable.filter', () => {129 test('returns an empty iterable when passed an empty iterable', () => {130 expect(iterable.filter([], x => x)).toBeEmpty();131 });132 test('invokes a predicate on elements from a nonempty iterable', () => {133 const isEven = x => x % 2 === 0;134 expect(iterable.filter([0, 1, 2, 3, 4], isEven)).toYield([0, 2, 4]);135 });136});137describe('iterable.reduce', () => {138 test('throws a TypeError when reducing an empty iterable with no initial value', () => {139 expect(() => iterable.reduce([], x => x)).toThrow(TypeError);140 });141 test('returns the initial value when called on an empty iterable', () => {142 expect(iterable.reduce([], x => 2 * x, 1)).toBe(1);143 });144 test('returns the first element when called with the identity function on a nonempty iterable', () => {145 expect(iterable.reduce([1, 2, 3], x => x)).toBe(1);146 });147 // Some accumulator functions148 const sum = (a, b) => a + b;149 const and = (a, b) => a && b;150 const or = (a, b) => a || b;151 test('accumulates the elements in a nonempty iterable', () => {152 expect(iterable.reduce([0, 1, 2, 3, 4], sum)).toBe(10);153 expect(iterable.reduce(['hello', ' ', 'world'], sum)).toBe('hello world');154 expect(iterable.reduce([true, true, true], and)).toBe(true);155 expect(iterable.reduce([true, true, true], or)).toBe(true);156 expect(iterable.reduce([true, false, true], and)).toBe(false);157 expect(iterable.reduce([true, false, true], or)).toBe(true);158 });159 test('accumulates the elements in a nonempty iterable with an initial value', () => {160 expect(iterable.reduce([0, 1, 2, 3, 4], sum, 10)).toBe(20);161 });162});163describe('iterable.take', () => {164 test('returns an empty iterable when the input iterable is empty', () => {165 expect(iterable.take(5, [])).toBeEmpty();166 });167 test('returns the first elements of an iterable', () => {168 expect(iterable.take(2, [1, 2, 3, 4])).toYield([1, 2]);169 });170 test('returns an empty iterable when `n < 1`', () => {171 expect(iterable.take(-1, [1, 2, 3, 4])).toBeEmpty();172 expect(iterable.take(0, [1, 2, 3, 4])).toBeEmpty();173 expect(iterable.take(0.8, [1, 2, 3, 4])).toBeEmpty();174 });175 test('can be called multiple times', () => {176 // Use a generator since they can't be iterated multiple times.177 function* generatorFunction() {178 yield 1;179 yield 2;180 yield 3;181 yield 4;182 yield 5;183 }184 const generator = generatorFunction();185 expect(iterable.take(2, generator)).toYield([1, 2]);186 expect(iterable.take(1, generator)).toYield([3]);187 expect(iterable.take(3, generator)).toYield([4, 5]);188 });189});190describe('iterable.skip', () => {191 test('returns an empty iterable when the input iterable is empty', () => {192 expect(iterable.skip(5, [])).toBeEmpty();193 });194 test('returns the last elements of an iterable', () => {195 expect(iterable.skip(2, [1, 2, 3, 4])).toYield([3, 4]);196 });197 test('returns the whole iterable when `n <= 0`', () => {198 expect(iterable.skip(-1, [1, 2, 3, 4])).toYield([1, 2, 3, 4]);199 expect(iterable.skip(0, [1, 2, 3, 4])).toYield([1, 2, 3, 4]);200 });201 test('can be called multiple times', () => {202 // Use a generator since they can't be iterated multiple times.203 function* generatorFunction() {204 yield 1;205 yield 2;206 yield 3;207 yield 4;208 yield 5;209 }210 let generator = generatorFunction();211 const multipleSkips = iterable.skip(1, iterable.skip(2, generator));212 expect(multipleSkips).toYield([4, 5]);213 generator = generatorFunction();214 generator = iterable.skip(2, generator)215 expect(iterable.take(1, generator)).toYield([3]);216 expect(iterable.skip(1, generator)).toYield([5]);217 });218});219describe('iterable.slice', () => {220 test('returns an empty iterable when the input iterable is empty', () => {221 expect(iterable.slice([], 2, 5)).toBeEmpty();222 });223 test('returns the last elements of an iterable when only `start` is given', () => {224 expect(iterable.slice([1, 2, 3, 4], 2)).toYield([3, 4]);225 });226 test('returns the elements between `start` and `end`', () => {227 expect(iterable.slice([1, 2, 3, 4, 5, 6], 2, 3)).toYield([3]);228 expect(iterable.slice([1, 2, 3, 4, 5, 6], 2, 4)).toYield([3, 4]);229 });230 test('works when `start` or `end` are at the boundaries of the iterable', () => {231 expect(iterable.slice([1, 2, 3, 4, 5, 6], 0, 3)).toYield([1, 2, 3]);232 expect(iterable.slice([1, 2, 3, 4, 5, 6], 2, 5)).toYield([3, 4, 5]);233 expect(iterable.slice([1, 2, 3, 4, 5, 6], 0, 5)).toYield([1, 2, 3, 4, 5]);234 });235 test('works when `start` or `end` are outside the boundaries of the iterable', () => {236 expect(iterable.slice([1, 2, 3, 4, 5, 6], -1, 3)).toYield([1, 2, 3]);237 expect(iterable.slice([1, 2, 3, 4, 5, 6], 2, 6)).toYield([3, 4, 5, 6]);238 expect(iterable.slice([1, 2, 3, 4, 5, 6], 0, 6)).toYield([1, 2, 3, 4, 5, 6]);239 expect(iterable.slice([1, 2, 3, 4, 5, 6], -1, 7)).toYield([1, 2, 3, 4, 5, 6]);240 });241 test('works with floating-point bounds', () => {242 expect(iterable.slice([1, 2, 3, 4, 5, 6], 0.2, 3.8)).toYield([1, 2, 3]);243 });244 test('returns an empty iterable when `start <= end`', () => {245 expect(iterable.slice([1, 2, 3, 4], 2, 1)).toBeEmpty();246 expect(iterable.slice([1, 2, 3, 4], 2, 2)).toBeEmpty();247 });248});249describe('iterable.flat', () => {250 test('returns an empty iterable when the input is empty', () => {251 expect(iterable.flat([])).toBeEmpty();252 });253 test('flattens 1-D arrays', () => {254 expect(iterable.flat([1, 2, 3, 4])).toYield([1, 2, 3, 4]);255 });256 test('flattens 2-D arrays', () => {257 const array2d = [258 ['a', 1], ['b', 2],259 ['c', 3], ['d', 4]260 ];261 expect(iterable.flat(array2d)).toYield(['a', 1, 'b', 2, 'c', 3, 'd', 4]);262 });263 test('flattens mixed-dimension arrays', () => {264 // Need to use `Array.from` + `toEqual` here.265 // `toYield` can't handle deep equality.266 expect(Array.from(iterable.flat([1, [2, 3, 4]]))).toEqual([1, 2, 3, 4]);267 expect(Array.from(iterable.flat([1, [2, [3, 4]]]))).toEqual([1, 2, [3, 4]]);268 expect(Array.from(iterable.flat([1, [2, [3, [4]]]]))).toEqual([1, 2, [3, [4]]]);269 });270 test('flattens up to `depth`', () => {271 expect(Array.from(iterable.flat([1, [2, [3, 4]]], 2))).toEqual([1, 2, 3, 4]);272 expect(Array.from(iterable.flat([1, [2, [3, [4]]]], 2))).toEqual([1, 2, 3, [4]]);273 expect(Array.from(iterable.flat([1, [2, [3, [4]]]], 3))).toEqual([1, 2, 3, 4]);274 });275 test('handles `depth` greater than the actual depth', () => {276 expect(Array.from(iterable.flat([1, 2, 3, 4], 2))).toEqual([1, 2, 3, 4]);277 expect(Array.from(iterable.flat([1, [2, 3, 4]], 2))).toEqual([1, 2, 3, 4]);278 expect(Array.from(iterable.flat([1, [2, [3, 4]]], 3))).toEqual([1, 2, 3, 4]);279 });280 test('treats nonpositive `depth` as a no-op', () => {281 expect(Array.from(iterable.flat([1, [2, 3, 4]], 0))).toEqual([1, [2, 3, 4]]);282 expect(Array.from(iterable.flat([1, [2, 3, 4]], -1))).toEqual([1, [2, 3, 4]]);283 expect(iterable.flat([], 0)).toBeEmpty();284 });285 test('rounds floating-point `depth` down', () => {286 expect(Array.from(iterable.flat([1, [2, 3, 4]], 0.1))).toEqual([1, [2, 3, 4]]);287 expect(Array.from(iterable.flat([1, [2, 3, 4]], 1.8))).toEqual([1, 2, 3, 4]);288 });289});290describe('iterable.flatMap', () => {291 test('returns an empty iterable when passed an empty iterable', () => {292 expect(iterable.flatMap([], x => x)).toBeEmpty();293 });294 test('invokes a function on a nonempty iterable', () => {295 // Need to use `Array.from` + `toEqual` here.296 // `toYield` can't handle deep equality.297 expect(Array.from(iterable.flatMap([1, 2, 3], x => [...new Array(x).keys()])))298 .toEqual([ 0, 0, 1, 0, 1, 2 ]);299 });300 test('is equivalent to `flat` when mapping the identity function', () => {301 expect(Array.from(iterable.flatMap([1, [2, 3, 4]], x => x))).toEqual([1, 2, 3, 4]);302 expect(Array.from(iterable.flatMap([1, [2, [3, 4]]], x => x))).toEqual([1, 2, [3, 4]]);303 expect(Array.from(iterable.flatMap([1, [2, [3, [4]]]], x => x))).toEqual([1, 2, [3, [4]]]);304 });305});306describe('iterable.product', () => {307 test('returns an empty iterable when one of the iterables is empty', () => {308 expect(iterable.product([], [])).toBeEmpty();309 expect(iterable.product(['a'], [])).toBeEmpty();310 expect(iterable.product([], ['a'])).toBeEmpty();311 });312 test('returns all permutations of nonempty iterables', () => {313 expect(iterable.product(['a', 'b', 'c'], [1, 2])).toYield([314 ['a', 1], ['a', 2],315 ['b', 1], ['b', 2],316 ['c', 1], ['c', 2]317 ], pairsStrictEqual);318 expect(iterable.product([1, 2], ['a', 'b', 'c'])).toYield([319 [1, 'a'], [1, 'b'], [1, 'c'],320 [2, 'a'], [2, 'b'], [2, 'c']321 ], pairsStrictEqual);322 });323 test('works when the one of the arguments is a generator', () => {324 function* generatorFunction() {...

Full Screen

Full Screen

TestUtils.ts

Source:TestUtils.ts Github

copy

Full Screen

...33export const runSingleDocumentRoundTripForTenant = async (client: TenantSecurityClient, tenant: string) => {34 const metadata = getMetadata(tenant);35 const data = getDataToEncrypt();36 const {edek, encryptedDocument} = await client.encryptDocument(data, metadata);37 expect(edek).not.toBeEmpty();38 assertEncryptedData(client, encryptedDocument);39 const decryptResult = await client.decryptDocument({edek, encryptedDocument}, metadata);40 expect(decryptResult.edek).toEqual(edek);41 expect(decryptResult.plaintextDocument.field1).toEqual(data.field1);42};43export const runSingleExistingDocumentRoundTripForTenant = async (client: TenantSecurityClient, tenant: string) => {44 const metadata = getMetadata(tenant);45 const data = getDataToEncrypt();46 const firstEncrypt = await client.encryptDocument(data, metadata);47 const {edek, encryptedDocument} = await client.encryptDocumentWithExistingKey({edek: firstEncrypt.edek, plaintextDocument: data}, metadata);48 expect(edek).not.toBeEmpty();49 assertEncryptedData(client, encryptedDocument);50 //Should be able to decrypt using the first EDEK we got back51 const res = await client.decryptDocument({edek: firstEncrypt.edek, encryptedDocument}, metadata);52 expect(res.edek).toEqual(edek);53 expect(res.plaintextDocument.field1).toEqual(data.field1);54 expect(res.plaintextDocument.field2).toEqual(data.field2);55 expect(res.plaintextDocument.field3).toEqual(data.field3);56};57export const runBatchDocumentRoundtripForTenant = async (client: TenantSecurityClient, tenant: string) => {58 const metadata = getMetadata(tenant);59 const data = getBatchDataToEncrypt();60 const encryptResult = await client.encryptDocumentBatch(data, metadata);61 expect(encryptResult.hasFailures).toBeFalse();62 expect(encryptResult.failures).toBeEmpty();63 expect(encryptResult.hasSuccesses).toBeTrue();64 expect(encryptResult.successes.batch1.edek).not.toBeEmpty();65 assertEncryptedData(client, encryptResult.successes.batch1.encryptedDocument);66 expect(encryptResult.successes.batch2.edek).not.toBeEmpty();67 assertEncryptedData(client, encryptResult.successes.batch2.encryptedDocument);68 expect(encryptResult.successes.batch3.edek).not.toBeEmpty();69 assertEncryptedData(client, encryptResult.successes.batch3.encryptedDocument);70 expect(encryptResult.successes.batch4.edek).not.toBeEmpty();71 assertEncryptedData(client, encryptResult.successes.batch4.encryptedDocument);72 expect(encryptResult.successes.batch5.edek).not.toBeEmpty();73 assertEncryptedData(client, encryptResult.successes.batch5.encryptedDocument);74 const decryptResult = await client.decryptDocumentBatch(encryptResult.successes, metadata);75 expect(decryptResult.hasFailures).toBeFalse();76 expect(decryptResult.failures).toBeEmpty();77 expect(decryptResult.hasSuccesses).toBeTrue();78 expect(decryptResult.successes.batch1.plaintextDocument).toEqual(data.batch1);79 expect(decryptResult.successes.batch2.plaintextDocument).toEqual(data.batch2);80 expect(decryptResult.successes.batch3.plaintextDocument).toEqual(data.batch3);81 expect(decryptResult.successes.batch4.plaintextDocument).toEqual(data.batch4);82 expect(decryptResult.successes.batch5.plaintextDocument).toEqual(data.batch5);83};84export const runReusedBatchDocumentRoundtripForTenant = async (client: TenantSecurityClient, tenant: string) => {85 const metadata = getMetadata(tenant);86 const data = getBatchDataToEncrypt();87 const firstEncrypt = await client.encryptDocumentBatch(data, metadata);88 expect(firstEncrypt.hasFailures).toBeFalse();89 expect(firstEncrypt.failures).toBeEmpty();90 expect(firstEncrypt.hasSuccesses).toBeTrue();91 expect(Object.values(firstEncrypt.successes)).toHaveLength(5);92 const dataForReEncrypt = Object.entries(firstEncrypt.successes).reduce((currentMap, [docId, {edek}]) => {93 currentMap[docId] = {edek, plaintextDocument: data[docId]};94 return currentMap;95 }, {} as PlaintextDocumentWithEdekCollection);96 const reencryptResult = await client.encryptDocumentBatchWithExistingKey(dataForReEncrypt, metadata);97 expect(reencryptResult.hasFailures).toBeFalse();98 expect(reencryptResult.failures).toBeEmpty();99 expect(reencryptResult.hasSuccesses).toBeTrue();100 expect(Object.values(reencryptResult.successes)).toHaveLength(5);101 expect(reencryptResult.successes.batch1.edek).not.toBeEmpty();102 assertEncryptedData(client, reencryptResult.successes.batch1.encryptedDocument);103 expect(reencryptResult.successes.batch2.edek).not.toBeEmpty();104 assertEncryptedData(client, reencryptResult.successes.batch2.encryptedDocument);105 expect(reencryptResult.successes.batch3.edek).not.toBeEmpty();106 assertEncryptedData(client, reencryptResult.successes.batch3.encryptedDocument);107 expect(reencryptResult.successes.batch4.edek).not.toBeEmpty();108 assertEncryptedData(client, reencryptResult.successes.batch4.encryptedDocument);109 expect(reencryptResult.successes.batch5.edek).not.toBeEmpty();110 assertEncryptedData(client, reencryptResult.successes.batch5.encryptedDocument);111 const decryptResult = await client.decryptDocumentBatch(reencryptResult.successes, metadata);112 expect(decryptResult.hasFailures).toBeFalse();113 expect(decryptResult.failures).toBeEmpty();114 expect(decryptResult.hasSuccesses).toBeTrue();115 expect(decryptResult.successes.batch1.plaintextDocument).toEqual(data.batch1);116 expect(decryptResult.successes.batch2.plaintextDocument).toEqual(data.batch2);117 expect(decryptResult.successes.batch3.plaintextDocument).toEqual(data.batch3);118 expect(decryptResult.successes.batch4.plaintextDocument).toEqual(data.batch4);119 expect(decryptResult.successes.batch5.plaintextDocument).toEqual(data.batch5);120};121export const runSingleDocumentRekeyRoundTripForTenants = async (client: TenantSecurityClient, tenant1: string, tenant2: string) => {122 const metadata = getMetadata(tenant1);123 const data = getDataToEncrypt();124 const encryptResult = await client.encryptDocument(data, metadata);125 expect(encryptResult.edek).not.toBeEmpty();126 assertEncryptedData(client, encryptResult.encryptedDocument);127 const rekeyResult = await client.rekeyDocument(encryptResult, tenant2, metadata);128 expect(rekeyResult.edek).not.toBeEmpty();129 assertEncryptedData(client, rekeyResult.encryptedDocument);130 expect(rekeyResult.encryptedDocument).toEqual(encryptResult.encryptedDocument);131 const newMetadata = getMetadata(tenant2);132 const decryptResult = await client.decryptDocument(rekeyResult, newMetadata);133 expect(decryptResult.edek).toEqual(rekeyResult.edek);134 expect(decryptResult.plaintextDocument.field1).toEqual(data.field1);...

Full Screen

Full Screen

expect.spec.ts

Source:expect.spec.ts Github

copy

Full Screen

...74 // Extracted example from their typings.75 // Reference: https://github.com/jest-community/jest-extended/blob/master/types/index.d.ts76 declare namespace jest {77 interface Matchers<R> {78 toBeEmpty(): R;79 }80 }81 `,82 'a.spec.ts': `83 const { test } = folio;84 test.expect('').toBeEmpty();85 test.expect('hello').not.toBeEmpty();86 test.expect([]).toBeEmpty();87 test.expect(['hello']).not.toBeEmpty();88 test.expect({}).toBeEmpty();89 test.expect({ hello: 'world' }).not.toBeEmpty();90 `91 });92 expect(result.exitCode).toBe(0);93});94test('should work with custom folio namespace', async ({runTSC}) => {95 const result = await runTSC({96 'global.d.ts': `97 // Extracted example from their typings.98 // Reference: https://github.com/jest-community/jest-extended/blob/master/types/index.d.ts99 declare namespace folio {100 interface Matchers<R> {101 toBeEmpty(): R;102 }103 }104 `,105 'a.spec.ts': `106 const { test } = folio;107 test.expect.extend({108 toBeWithinRange() { },109 });110 test.expect('').toBeEmpty();111 test.expect('hello').not.toBeEmpty();112 test.expect([]).toBeEmpty();113 test.expect(['hello']).not.toBeEmpty();114 test.expect({}).toBeEmpty();115 test.expect({ hello: 'world' }).not.toBeEmpty();116 `117 });118 expect(result.exitCode).toBe(0);...

Full Screen

Full Screen

log.test.js

Source:log.test.js Github

copy

Full Screen

...32 expect(transport.filename).toMatch(fileRegex);33 });34 });35 test('Log Errors', async () => {36 expect(logFrom('error')).toBeEmpty();37 logger.info('This is not written as an error');38 await sleep(500);39 expect(logFrom('error')).toBeEmpty();40 logger.error('This is an error log');41 await sleep(500);42 const errorLog = logFrom('error');43 expect(errorLog.length).toBe(1);44 const { timestamp, ...item } = errorLog[0];45 expect(item).toEqual({46 message: 'This is an error log',47 service: 'testing',48 level: 'error',49 });50 });51 test('Log Level', async () => {52 expect(logFrom('error')).toBeEmpty();53 expect(logFrom(logLevel)).toBeEmpty();54 expect(logFrom(today())).toBeEmpty();55 logger.log(logLevel, 'This is a level log');56 await sleep(500);57 expect(logFrom('error')).toBeEmpty();58 expect(logFrom(logLevel)).not.toBeEmpty();59 expect(logFrom(today())).not.toBeEmpty();60 expect(logFrom(logLevel)).toEqual(logFrom(today()));61 const currentLog = logFrom(logLevel);62 expect(currentLog.length).toBe(1);63 const { timestamp, ...item } = currentLog[0];64 expect(item).toEqual({65 level: logLevel,66 message: 'This is a level log',67 });68 });69 test('Log Daily', async () => {70 expect(logFrom(logLevel)).toBeEmpty();71 expect(logFrom('error')).toBeEmpty();72 expect(logFrom(today())).toBeEmpty();73 logger.error('This is a daily log');74 await sleep(500);75 expect(logFrom(logLevel)).not.toBeEmpty();76 expect(logFrom('error')).not.toBeEmpty();77 expect(logFrom(today())).not.toBeEmpty();78 expect(logFrom(today())).toEqual(logFrom(logLevel));79 expect(logFrom(today())).toEqual(logFrom('error'));80 const currentLog = logFrom(today());81 expect(currentLog.length).toBe(1);82 const { timestamp, ...item } = currentLog[0];83 expect(item).toEqual({84 level: 'error',85 service: 'testing',86 message: 'This is a daily log',87 });88 });...

Full Screen

Full Screen

database.test.js

Source:database.test.js Github

copy

Full Screen

...18 ['translationText', 'this is a teste'], ['user', 'user1']])19 .toContainKey('dateTranslated');20 expect(data.ops[0].dateTranslated)21 .toBeString()22 .not.toBeEmpty();23 insertedDBId = data.insertedId;24});25test('Happy path Search in DB', async () => {26 const data = await db.findindb('user1', insertedDBId);27 expect(data)28 .toBeObject()29 .toContainAllKeys(['_id', 'user', 'originalLanguage', 'originalText', 'translationLanguage',30 'translationText', 'dateTranslated', 'channel', 'receiver']);31 expect(data.user)32 .toBeString()33 .not.toBeEmpty()34 .toEqualCaseInsensitive('user1');35 expect(data.originalLanguage)36 .toBeString()37 .not.toBeEmpty()38 .toEqualCaseInsensitive('en');39 expect(data.originalText)40 .toBeString()41 .not.toBeEmpty()42 .toEqualCaseInsensitive('this is a test');43 expect(data.translationLanguage)44 .toBeString()45 .not.toBeEmpty()46 .toEqualCaseInsensitive('fr');47 expect(data.translationText)48 .toBeString()49 .not.toBeEmpty()50 .toEqualCaseInsensitive('this is a teste');51 expect(data.channel)52 .toBeString()53 .not.toBeEmpty()54 .toEqualCaseInsensitive('channel');55 expect(data.receiver)56 .toBeString()57 .not.toBeEmpty()58 .toEqualCaseInsensitive('receiver');59 expect(data.dateTranslated)60 .toBeString()61 .not.toBeEmpty();62});63test('Search in DB, id not found', async () => {64 // Sending bad id65 const data = await db.findindb('user1', '123456789012345678abcdef');66 expect(data)67 .toBeObject()68 .toBeEmpty();69});70test('Search in DB, invalid id', async () => {71 // Sending invalid id72 const data = await db.findindb('user1', 'badId');73 expect(data)74 .toBeString()75 .not.toBeEmpty()76 .toEqualCaseInsensitive('Invalid ID, must be a single String of 12 bytes or a string of 24 hex characters');...

Full Screen

Full Screen

to-be-empty.js

Source:to-be-empty.js Github

copy

Full Screen

...3 value: true4});5exports.toBeEmpty = toBeEmpty;6var _utils = require("./utils");7function toBeEmpty(element) {8 (0, _utils.deprecate)('toBeEmpty', 'Please use instead toBeEmptyDOMElement for finding empty nodes in the DOM.');9 (0, _utils.checkHtmlElement)(element, toBeEmpty, this);10 return {11 pass: element.innerHTML === '',12 message: () => {13 return [this.utils.matcherHint(`${this.isNot ? '.not' : ''}.toBeEmpty`, 'element', ''), '', 'Received:', ` ${this.utils.printReceived(element.innerHTML)}`].join('\n');14 }15 };...

Full Screen

Full Screen

to-be-empty 2.js

Source:to-be-empty 2.js Github

copy

Full Screen

...3 value: true4});5exports.toBeEmpty = toBeEmpty;6var _utils = require("./utils");7function toBeEmpty(element) {8 (0, _utils.deprecate)('toBeEmpty', 'Please use instead toBeEmptyDOMElement for finding empty nodes in the DOM.');9 (0, _utils.checkHtmlElement)(element, toBeEmpty, this);10 return {11 pass: element.innerHTML === '',12 message: () => {13 return [this.utils.matcherHint(`${this.isNot ? '.not' : ''}.toBeEmpty`, 'element', ''), '', 'Received:', ` ${this.utils.printReceived(element.innerHTML)}`].join('\n');14 }15 };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 const title = page.locator('title');4 await expect(title).toBeEmpty();5});6const { test, expect } = require('@playwright/test');7test('test', async ({ page }) => {8 const title = page.locator('title');9 await expect(title).toBeEmpty();10});11const { test, expect } = require('@playwright/test');12test('test', async ({ page }) => {13 const title = page.locator('title');14 await expect(title).toBeEmpty();15});16const { test, expect } = require('@playwright/test');17test('test', async ({ page }) => {18 const title = page.locator('title');19 await expect(title).toBeEmpty();20});21const { test, expect } = require('@playwright/test');22test('test', async ({ page }) => {23 const title = page.locator('title');24 await expect(title).toBeEmpty();25});26const { test, expect } = require('@playwright/test');27test('test', async ({ page }) => {28 const title = page.locator('title');29 await expect(title).toBeEmpty();30});31const { test, expect } = require('@playwright/test');32test('test', async ({ page }) => {33 const title = page.locator('title');34 await expect(title).toBeEmpty();35});36const { test, expect } = require('@playwright/test');37test('test', async ({ page }) => {38 await page.goto('

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 const element = await page.$('text=Get Started');4 expect(element).toBeEmpty();5});6expect(element).toBeEmpty();7const { test, expect } = require('@playwright/test');8test('test', async ({ page }) => {9 const element = await page.$('text=Get Started');10 expect(element).toBeEmpty();11});12toBeDisabled()13toBeEditable()14toBeEnabled()15toBeFocused()16toBeHidden()17toBeVisible()18toHaveAttribute()19toHaveClass()20toHaveCount()21toHaveFocus()22toHaveInputMode()23toHaveText()24toHaveURL()25toHaveValue()26toHaveValueCount()27toIncludeText()28toSelectOptions()29toShowContextMenu()30toType()31toUncheck()32toUploadFile()

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('test', async ({ page }) => {3 const element = await page.$('div');4 await expect(element).toBeEmpty();5});6const { test, expect } = require('@playwright/test');7test('test', async ({ page }) => {8 const element = await page.$('div');9 await expect(element).toBeEmpty();10});11const { test, expect } = require('@playwright/test');12test('test', async ({ page }) => {13 const element = await page.$('div');14 await expect(element).toBeEmpty();15});16const { test, expect } = require('@playwright/test');17test('test', async ({ page }) => {18 const element = await page.$('div');19 await expect(element).toBeEmpty();20});21const { test, expect } = require('@playwright/test');22test('test', async ({ page }) => {23 const element = await page.$('div');24 await expect(element).toBeEmpty();25});26const { test, expect } = require('@playwright/test');27test('test', async ({ page }) => {28 const element = await page.$('div');29 await expect(element).toBeEmpty();30});31const { test, expect } = require('@playwright/test');32test('test', async ({ page }) => {33 const element = await page.$('div');34 await expect(element).toBeEmpty();35});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('toBeEmpty', async ({ page }) => {3 await page.setContent('<div id="empty"></div><div id="not-empty">not empty</div>');4 const empty = page.locator('#empty');5 const notEmpty = page.locator('#not-empty');6 await expect(empty).toBeEmpty();7 await expect(notEmpty).not.toBeEmpty();8});9const { test, expect } = require('@playwright/test');10test('toBeEmpty', async ({ page }) => {11 await page.setContent('<div id="empty"></div><div id="not-empty">not empty</div>');12 const empty = page.locator('#empty');13 const notEmpty = page.locator('#not-empty');14 await expect(empty).toBeEmpty();15 await expect(notEmpty).not.toBeEmpty();16});17const { test, expect } = require('@playwright/test');18test('toBeEmpty', async ({ page }) => {19 await page.setContent('<div id="empty"></div><div id="not-empty">not empty</div>');20 const empty = page.locator('#empty');21 const notEmpty = page.locator('#not-empty');22 await expect(empty).toBeEmpty();23 await expect(notEmpty).not.toBeEmpty();24});25const { test, expect } = require('@playwright/test');26test('toBeEmpty', async ({ page }) => {27 await page.setContent('<div id="empty"></div><div id="not-empty">not empty</div>');28 const empty = page.locator('#empty');29 const notEmpty = page.locator('#not-empty');30 await expect(empty).toBeEmpty();31 await expect(notEmpty).not.toBeEmpty();32});33const { test, expect } = require('@playwright/test');34test('toBeEmpty', async ({ page }) => {35 await page.setContent('<div id="empty"></div><div id="not-empty">not empty</div>');36 const empty = page.locator('#empty');37 const notEmpty = page.locator('#not-empty');38 await expect(empty).toBe

Full Screen

Using AI Code Generation

copy

Full Screen

1const { test, expect } = require('@playwright/test');2test('validate empty element', async ({ page }) => {3 const element = await page.$('text=Get started');4 await expect(element).toBeEmpty();5});6const { test, expect } = require('@playwright/test');7test('validate empty element', async ({ page }) => {8 const element = await page.$('text=Get started');9 await expect(element).toBeEmpty();10});11const { test, expect } = require('@playwright/test');12test('validate empty element', async ({ page }) => {13 const element = await page.$('text=Get started');14 await expect(element).toBeEmpty();15});16const { test, expect } = require('@playwright/test');17test('validate empty element', async ({ page }) => {18 const element = await page.$('text=Get started');19 await expect(element).toBeEmpty();20});21const { test, expect } = require('@playwright/test');22test('validate empty element', async ({ page }) => {23 const element = await page.$('text=Get started');24 await expect(element).toBeEmpty();25});26const { test, expect } = require('@playwright/test');27test('validate empty element', async ({ page }) => {28 const element = await page.$('text=Get started');29 await expect(element).toBeEmpty();30});31const { test, expect } = require('@playwright/test');32test('validate empty element', async ({ page }) => {33 const element = await page.$('text=Get

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful