Skip to content

Commit 73d6b8a

Browse files
committed
Remove testing against localhost
1 parent ad87eb3 commit 73d6b8a

File tree

7 files changed

+16
-29
lines changed

7 files changed

+16
-29
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Run tests
2525
env:
2626
SERPAPI_TEST_KEY: ${{ secrets.SERPAPI_TEST_KEY }}
27-
run: deno task test:ci
27+
run: deno task test
2828

2929
- name: Setup Node
3030
uses: actions/setup-node@v4

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Run tests
2929
env:
3030
SERPAPI_TEST_KEY: ${{ secrets.SERPAPI_TEST_KEY }}
31-
run: deno task test:ci
31+
run: deno task test
3232

3333
- name: Setup Node
3434
uses: actions/setup-node@v4

CONTRIBUTING.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ and you're good to go.
6666

6767
### Tests that require an API key
6868

69-
- When testing functionality that hits either `localhost` or
70-
`https://serpapi.com`, and requires an API key, you need to ensure your API
69+
- When testing functionality that requires an API key, you need to ensure your API
7170
key is specified as an environment variable.
7271
- Create a `.env` file with the following contents, replacing `YOUR_API_KEY`
7372
with your API key for the appropriate environment.
@@ -91,10 +90,9 @@ it("getJson with api key from config", {
9190
## Run tests
9291

9392
```bash
94-
deno task test # Run tests that hit "localhost"
95-
deno task test:watch # Run tests that hit "localhost" and in watch mode: https://deno.land/manual/getting_started/command_line_interface#watch-mode
96-
deno task test:cov # Get test coverage by running tests that hit "localhost"
97-
deno task test:ci # Run tests that hit "https://serpapi.com"
93+
deno task test # Run tests
94+
deno task test:watch # Run tests and in watch mode: https://deno.land/manual/getting_started/command_line_interface#watch-mode
95+
deno task test:cov # Get test coverage by running tests
9896
```
9997

10098
## Run examples on local source files

deno.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"tasks": {
33
"docs:gen": "npx documentation readme src/serpapi.ts --section=Functions --shallow && deno fmt",
4-
"test": "ENV_TYPE=local deno test tests/ --allow-env --allow-read --allow-net --fail-fast",
4+
"test": "deno test tests/ --allow-env --allow-read --allow-net",
55
"test:watch": "deno task test --watch",
66
"test:cov": "rm -rf cov_profile && deno task test --coverage=cov_profile && deno coverage cov_profile",
7-
"test:ci": "deno test tests/ --allow-env --allow-read --allow-net",
87
"npm": "deno run -A scripts/build_npm.ts"
98
},
109
"fmt": {

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const _internals = {
1818
getHostnameAndPort: getHostnameAndPort,
1919
};
2020

21-
/** Facilitates stubbing in tests, e.g. localhost as the base url */
21+
/** Facilitates stubbing in tests */
2222
function getHostnameAndPort() {
2323
return {
2424
hostname: "serpapi.com",

tests/serpapi_test.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,10 @@ import {
4040
loadSync({ export: true });
4141
const SERPAPI_TEST_KEY = Deno.env.get("SERPAPI_TEST_KEY") ?? "";
4242
const HAS_API_KEY = SERPAPI_TEST_KEY.length > 0;
43-
const BASE_OPTIONS = Deno.env.get("ENV_TYPE") === "local"
44-
? {
45-
hostname: "localhost",
46-
port: 3000,
47-
}
48-
: {
49-
hostname: "serpapi.com",
50-
port: 443,
51-
};
43+
const BASE_OPTIONS = {
44+
hostname: "serpapi.com",
45+
port: 443,
46+
};
5247

5348
describe(
5449
"getAccount",

tests/utils_test.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@ import http from "node:http";
2323
import qs from "node:querystring";
2424

2525
loadSync({ export: true });
26-
const BASE_OPTIONS = Deno.env.get("ENV_TYPE") === "local"
27-
? {
28-
hostname: "localhost",
29-
port: 3000,
30-
}
31-
: {
32-
hostname: "serpapi.com",
33-
port: 443,
34-
};
26+
const BASE_OPTIONS = {
27+
hostname: "serpapi.com",
28+
port: 443,
29+
};
3530

3631
describe("getSource", () => {
3732
it("use runtime version", async () => {

0 commit comments

Comments
 (0)