@eyeo/get-browser-binary 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) 2006-present eyeo GmbH
3
+ *
4
+ * This module is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import {startTestServer} from "./test-server.js";
19
+
20
+ startTestServer();
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright (c) 2006-present eyeo GmbH
3
+ *
4
+ * This module is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU General Public License as published by
6
+ * the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+
18
+ import path from "path";
19
+ import url from "url";
20
+ import express from "express";
21
+
22
+ const HOST = "localhost";
23
+ const PORT = 3000;
24
+
25
+ export const TEST_SERVER_URL = `http://${HOST}:${PORT}`;
26
+
27
+ let app = express();
28
+ let dirname = path.dirname(url.fileURLToPath(import.meta.url));
29
+
30
+ app.use(express.static(path.join(dirname, "pages")));
31
+
32
+ export function startTestServer() {
33
+ app.listen(PORT, HOST, () => {
34
+ // eslint-disable-next-line no-console
35
+ console.log(`Test server listening at ${TEST_SERVER_URL}`);
36
+ });
37
+ }
package/test/utils.js CHANGED
@@ -20,14 +20,15 @@ import {expect} from "expect";
20
20
  import path from "path";
21
21
 
22
22
  import {snapshotsBaseDir, download} from "../index.js";
23
+ import {TEST_SERVER_URL} from "./test-server.js";
23
24
 
24
25
  describe("Utils", () => {
25
26
  it("defines a browser snapshots folder", () => expect(snapshotsBaseDir)
26
27
  .toBe(path.join(process.cwd(), "browser-snapshots")));
27
28
 
28
- let resourceUrl = "https://gitlab.com/eyeo/developer-experience/get-browser-binary/-/raw/main/package.json";
29
+ let resourceUrl = `${TEST_SERVER_URL}/download-test.txt`;
29
30
  let destFile = path.join(snapshotsBaseDir, "download-test.txt");
30
- let expectedFileContents = "\"name\": \"@eyeo/get-browser-binary\"";
31
+ const expectedFileContents = "Download test";
31
32
 
32
33
  it("downloads resources", async() => {
33
34
  await fs.promises.rm(destFile, {force: true});
@@ -45,11 +46,11 @@ describe("Utils", () => {
45
46
 
46
47
  it("does not download on short timeout", async() => {
47
48
  try {
48
- await download(resourceUrl, destFile, 10);
49
+ await download(resourceUrl, destFile, 1);
49
50
  throw new Error("Download timeout didn't throw");
50
51
  }
51
52
  catch (err) {
52
- expect(err).toBe("Download timeout after 10ms");
53
+ expect(err).toBe("Download timeout after 1ms");
53
54
  }
54
55
  });
55
56