1 | import { expectAssignable, expectType } from 'tsd';
|
2 | import { NightwatchAPI, NightwatchLogEntry, NightwatchLogTypes } from '..';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | describe('get log from Selenium', function() {
|
9 | it('get browser log (default)', function(browser) {
|
10 | const result = browser.logs.getSessionLog(function(result) {
|
11 | expectType<NightwatchAPI>(this);
|
12 | if (result.status === 0) {
|
13 | const logEntriesArray = result.value;
|
14 | expectType<NightwatchLogEntry[]>(logEntriesArray);
|
15 | }
|
16 | });
|
17 | expectAssignable<NightwatchAPI>(result);
|
18 |
|
19 | browser.logs.getSessionLog('client', function(result) {
|
20 | expectType<NightwatchAPI>(this);
|
21 | if (result.status === 0) {
|
22 | const logEntriesArray = result.value;
|
23 | expectType<NightwatchLogEntry[]>(logEntriesArray);
|
24 | }
|
25 | });
|
26 | });
|
27 |
|
28 | it('get driver log with ES6 async/await', async function(browser) {
|
29 | const driverLogAvailable = await browser.logs.isSessionLogAvailable('driver');
|
30 | expectType<boolean>(driverLogAvailable);
|
31 |
|
32 | if (driverLogAvailable) {
|
33 | const logEntriesArray = await browser.logs.getSessionLog('driver');
|
34 | expectType<NightwatchLogEntry[]>(logEntriesArray);
|
35 | }
|
36 | });
|
37 | });
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | describe('get available log types', function() {
|
43 | it('get log types', function(browser) {
|
44 | const result = browser.logs.getSessionLogTypes(function(result) {
|
45 | expectType<NightwatchAPI>(this);
|
46 | if (result.status === 0) {
|
47 | const logTypes = result.value;
|
48 | expectType<NightwatchLogTypes[]>(logTypes);
|
49 | }
|
50 | });
|
51 | expectAssignable<NightwatchAPI>(result);
|
52 | });
|
53 |
|
54 | it('get log types with ES6 async/await', async function(browser) {
|
55 | const logTypes = await browser.logs.getSessionLogTypes();
|
56 | expectType<NightwatchLogTypes[]>(logTypes);
|
57 | });
|
58 | });
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | describe('test if the log type is available', function() {
|
64 | it('test browser log type', function(browser) {
|
65 | const result = browser.logs.isSessionLogAvailable(function(result) {
|
66 | expectType<NightwatchAPI>(this);
|
67 | if (result.status === 0) {
|
68 | const isAvailable = result.value;
|
69 | expectType<boolean>(isAvailable);
|
70 | }
|
71 | });
|
72 | expectAssignable<NightwatchAPI>(result);
|
73 |
|
74 | browser.logs.isSessionLogAvailable('performance', function(result) {
|
75 | expectType<NightwatchAPI>(this);
|
76 | if (result.status === 0) {
|
77 | const isAvailable = result.value;
|
78 | expectType<boolean>(isAvailable);
|
79 | }
|
80 | });
|
81 | });
|
82 |
|
83 | it('test driver log type with ES6 async/await', async function(browser) {
|
84 | const isAvailable = await browser.logs.isSessionLogAvailable('driver');
|
85 | expectType<boolean>(isAvailable);
|
86 | if (isAvailable) {
|
87 |
|
88 | }
|
89 | });
|
90 | });
|