Skip to content

Commit 4ab4937

Browse files
committed
Full run with more logging
1 parent 3a25d30 commit 4ab4937

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

tests/smoke/commonjs/commonjs.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const run = async () => {
1818

1919
let searchId;
2020

21-
// getJson async await
2221
{
22+
console.log("getJson async await");
2323
const page1 = await getJson("google", params);
2424
searchId = page1["search_metadata"]["id"];
2525
if (!page1["organic_results"]) throw new Error("No organic results");
@@ -29,8 +29,8 @@ const run = async () => {
2929
}
3030
}
3131

32-
// getJson callback
3332
{
33+
console.log("getJson callback");
3434
getJson("google", params, (page1) => {
3535
if (!page1["organic_results"]) throw new Error("No organic results");
3636
if (page1.next) {
@@ -41,8 +41,8 @@ const run = async () => {
4141
});
4242
}
4343

44-
// getJson using global config
4544
{
45+
console.log("getJson using global config");
4646
config.api_key = apiKey;
4747
const page1 = await getJson("google", { q: "Coffee" });
4848
if (!page1["organic_results"]) throw new Error("No organic results");
@@ -52,8 +52,8 @@ const run = async () => {
5252
}
5353
}
5454

55-
// getJson pagination loop (async/await)
5655
{
56+
console.log("getJson pagination loop (async/await)");
5757
const links = [];
5858
let page = await getJson("google", params);
5959
while (page) {
@@ -64,8 +64,8 @@ const run = async () => {
6464
if (links.length < 30) throw new Error("Incorrect number of links");
6565
}
6666

67-
// getJson pagination loop (callback)
6867
{
68+
console.log("getJson pagination loop (callback)");
6969
const links = [];
7070
getJson("google", params, (page) => {
7171
links.push(...page.organic_results.map(r => r.link));
@@ -77,8 +77,8 @@ const run = async () => {
7777
});
7878
}
7979

80-
// getHtml
8180
{
81+
console.log("getHtml");
8282
const html = await getHtml("google", params);
8383
if (html.length < 1000) throw new Error("Incorrect HTML");
8484

@@ -87,8 +87,8 @@ const run = async () => {
8787
});
8888
}
8989

90-
// getJsonBySearchId
9190
{
91+
console.log("getJsonBySearchId");
9292
config.api_key = apiKey;
9393
const json = await getJsonBySearchId(searchId);
9494
if (!json["organic_results"]) throw new Error("No organic results");
@@ -98,8 +98,8 @@ const run = async () => {
9898
});
9999
}
100100

101-
// getHtmlBySearchId
102101
{
102+
console.log("getHtmlBySearchId");
103103
config.api_key = apiKey;
104104
const html = await getHtmlBySearchId(searchId);
105105
if (html.length < 1000) throw new Error("Incorrect HTML");
@@ -109,8 +109,8 @@ const run = async () => {
109109
});
110110
}
111111

112-
// getAccount
113112
{
113+
console.log("getAccount");
114114
config.api_key = apiKey;
115115
const info = await getAccount();
116116
if (!info["account_email"]) throw new Error("Incorrect account info");
@@ -120,8 +120,8 @@ const run = async () => {
120120
});
121121
}
122122

123-
// getLocations
124123
{
124+
console.log("getLocations");
125125
const locations = await getLocations({ limit: 3 });
126126
if (locations.length !== 3) throw new Error("Incorrect locations length");
127127

tests/smoke/esm/esm.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ const params = {
1717

1818
let searchId;
1919

20-
// getJson async await
2120
{
21+
console.log("getJson async await")
2222
const page1 = await getJson("google", params);
2323
searchId = page1["search_metadata"]["id"];
2424
if (!page1["organic_results"]) throw new Error("No organic results");
2525
const page2 = await page1.next?.();
2626
if (!page2["organic_results"]) throw new Error("No organic results");
2727
}
2828

29-
// getJson callback
3029
{
30+
console.log("getJson callback")
3131
getJson("google", params, (page1) => {
3232
if (!page1["organic_results"]) throw new Error("No organic results");
3333
page1.next?.((page2) => {
@@ -36,17 +36,17 @@ let searchId;
3636
});
3737
}
3838

39-
// getJson using global config
4039
{
40+
console.log("getJson using global config")
4141
config.api_key = apiKey;
4242
const page1 = await getJson("google", { q: "Coffee" });
4343
if (!page1["organic_results"]) throw new Error("No organic results");
4444
const page2 = await page1.next?.();
4545
if (!page2["organic_results"]) throw new Error("No organic results");
4646
}
4747

48-
// getJson pagination loop (async/await)
4948
{
49+
console.log("getJson pagination loop (async/await)")
5050
const links = [];
5151
let page = await getJson("google", params);
5252
while (page) {
@@ -57,8 +57,8 @@ let searchId;
5757
if (links.length < 30) throw new Error("Incorrect number of links");
5858
}
5959

60-
// getJson pagination loop (callback)
6160
{
61+
console.log("getJson pagination loop (callback)")
6262
const links = [];
6363
getJson("google", params, (page) => {
6464
links.push(...page.organic_results.map(r => r.link));
@@ -70,8 +70,8 @@ let searchId;
7070
});
7171
}
7272

73-
// getHtml
7473
{
74+
console.log("getHtml")
7575
const html = await getHtml("google", params);
7676
if (html.length < 1000) throw new Error("Incorrect HTML");
7777

@@ -80,8 +80,8 @@ let searchId;
8080
});
8181
}
8282

83-
// getJsonBySearchId
8483
{
84+
console.log("getJsonBySearchId")
8585
config.api_key = apiKey;
8686
const json = await getJsonBySearchId(searchId);
8787
if (!json["organic_results"]) throw new Error("No organic results");
@@ -91,8 +91,8 @@ let searchId;
9191
});
9292
}
9393

94-
// getHtmlBySearchId
9594
{
95+
console.log("getHtmlBySearchId")
9696
config.api_key = apiKey;
9797
const html = await getHtmlBySearchId(searchId);
9898
if (html.length < 1000) throw new Error("Incorrect HTML");
@@ -102,8 +102,8 @@ let searchId;
102102
});
103103
}
104104

105-
// getAccount
106105
{
106+
console.log("getAccount")
107107
config.api_key = apiKey;
108108
const info = await getAccount();
109109
if (!info["account_email"]) throw new Error("Incorrect account info");
@@ -113,8 +113,8 @@ let searchId;
113113
});
114114
}
115115

116-
// getLocations
117116
{
117+
console.log("getLocations")
118118
const locations = await getLocations({ limit: 3 });
119119
if (locations.length !== 3) throw new Error("Incorrect locations length");
120120

0 commit comments

Comments
 (0)