Ver código fonte

test(e2e): refactor e2e tests

Jonas Gloning 1 ano atrás
pai
commit
4cc1c81406

+ 5 - 2
e2e/data.js

@@ -31,7 +31,7 @@ export const strings = [
 
 export { commit_data } from "./commit_data.js";
 
-export const typed_arrays = [
+export const uint8_arrays = [
 	new Uint8Array(),
 	new Uint8Array([0]),
 	new Uint8Array([0, 1, 2, 3, 4, 6, 7]),
@@ -40,6 +40,9 @@ export const typed_arrays = [
 		0, 1, 2, 3, 4, 6, 78, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23,
 		24, 25, 26, 27, 28, 30, 31,
 	]),
+];
+
+export const int32_arrays = [
 	new Int32Array([0].map((x) => -x)),
 	new Int32Array([0, 1, 2, 3, 4, 6, 7].map((x) => -x)),
 	new Int32Array(
@@ -53,7 +56,7 @@ export const typed_arrays = [
 	),
 ];
 
-export const typed_array_view = new Uint8Array(typed_arrays[6].buffer, 4);
+export const typed_array_view = new Uint8Array(uint8_arrays[4].buffer, 4);
 
 export const array_buffers = [
 	new Uint8Array(),

+ 18 - 0
e2e/datachannel/Int32Array_as_ArrayBuffer.js

@@ -0,0 +1,18 @@
+import { int32_arrays } from "../data.js";
+import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
+
+/** @param {unknown[]} received */
+export const check = (received) => {
+	for (const [i, typed_array] of int32_arrays.entries()) {
+		expect(received[i]).to.be.an.instanceof(ArrayBuffer);
+		expect(new Int32Array(received[i])).to.deep.equal(typed_array);
+	}
+};
+/**
+ * @param {import("../peerjs").DataConnection} dataConnection
+ */
+export const send = (dataConnection) => {
+	for (const typed_array of int32_arrays) {
+		dataConnection.send(typed_array);
+	}
+};

+ 17 - 0
e2e/datachannel/TypedArrayView_as_ArrayBuffer.js

@@ -0,0 +1,17 @@
+import { typed_array_view } from "../data.js";
+import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
+
+/** @param {unknown[]} received */
+export const check = (received) => {
+	const received_typed_array_view = received[0];
+	expect(received_typed_array_view).to.be.instanceOf(ArrayBuffer);
+	expect(new Uint8Array(received_typed_array_view)).to.deep.equal(
+		typed_array_view,
+	);
+};
+/**
+ * @param {import("../peerjs").DataConnection} dataConnection
+ */
+export const send = (dataConnection) => {
+	dataConnection.send(typed_array_view);
+};

+ 18 - 0
e2e/datachannel/Uint8Array_as_ArrayBuffer.js

@@ -0,0 +1,18 @@
+import { uint8_arrays } from "../data.js";
+import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
+
+/** @param {unknown[]} received */
+export const check = (received) => {
+	for (const [i, typed_array] of uint8_arrays.entries()) {
+		expect(received[i]).to.be.an.instanceof(ArrayBuffer);
+		expect(new Uint8Array(received[i])).to.deep.equal(typed_array);
+	}
+};
+/**
+ * @param {import("../peerjs").DataConnection} dataConnection
+ */
+export const send = (dataConnection) => {
+	for (const typed_array of uint8_arrays) {
+		dataConnection.send(typed_array);
+	}
+};

+ 5 - 24
e2e/datachannel/arraybuffers.js

@@ -1,37 +1,18 @@
-import { typed_arrays, typed_array_view, array_buffers } from "../data.js";
+import { array_buffers } from "../data.js";
 import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
 
 /** @param {unknown[]} received */
-window.check = (received) => {
-	for (const [i, typed_array] of typed_arrays.entries()) {
-		expect(received[i]).to.be.an.instanceof(ArrayBuffer);
-		expect(received[i]).to.deep.equal(typed_array.buffer);
-	}
+export const check = (received) => {
 	for (const [i, array_buffer] of array_buffers.entries()) {
-		expect(received[typed_arrays.length + i]).to.be.an.instanceof(ArrayBuffer);
-		expect(received[typed_arrays.length + i]).to.deep.equal(array_buffer);
-	}
-
-	const received_typed_array_view =
-		received[typed_arrays.length + array_buffers.length];
-	expect(new Uint8Array(received_typed_array_view)).to.deep.equal(
-		typed_array_view,
-	);
-	for (const [i, v] of new Uint8Array(received_typed_array_view).entries()) {
-		expect(v).to.deep.equal(typed_array_view[i]);
+		expect(received[i]).to.be.an.instanceof(ArrayBuffer);
+		expect(received[i]).to.deep.equal(array_buffer);
 	}
 };
 /**
  * @param {import("../peerjs").DataConnection} dataConnection
  */
-window.send = (dataConnection) => {
-	for (const typed_array of typed_arrays) {
-		dataConnection.send(typed_array);
-	}
+export const send = (dataConnection) => {
 	for (const array_buffer of array_buffers) {
 		dataConnection.send(array_buffer);
 	}
-	dataConnection.send(typed_array_view);
 };
-
-window["connect-btn"].disabled = false;

+ 3 - 3
e2e/datachannel/arrays.js

@@ -2,14 +2,14 @@ import { commit_data } from "../data.js";
 import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
 
 /** @param {unknown[]} received */
-window.check = (received) => {
+export const check = (received) => {
+	expect(received[1]).to.be.an("array").with.lengthOf(commit_data.length);
 	expect(received).to.deep.equal([[], commit_data]);
 };
 /**
  * @param {import("../peerjs").DataConnection} dataConnection
  */
-window.send = (dataConnection) => {
+export const send = (dataConnection) => {
 	dataConnection.send([]);
 	dataConnection.send(commit_data);
 };
-window["connect-btn"].disabled = false;

+ 2 - 3
e2e/datachannel/arrays_json.js → e2e/datachannel/arrays_unchunked.js

@@ -6,14 +6,13 @@ import { commit_data } from "../data.js";
 import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
 
 /** @param {unknown[]} received */
-window.check = (received) => {
+export const check = (received) => {
 	expect(received).to.deep.equal([[], commit_data.slice(0, 2)]);
 };
 /**
  * @param {import("../peerjs").DataConnection} dataConnection
  */
-window.send = (dataConnection) => {
+export const send = (dataConnection) => {
 	dataConnection.send([]);
 	dataConnection.send(commit_data.slice(0, 2));
 };
-window["connect-btn"].disabled = false;

+ 16 - 0
e2e/datachannel/dates_as_json_string.js

@@ -0,0 +1,16 @@
+import { dates } from "../data.js";
+import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
+
+/** @param {unknown[]} received */
+export const check = (received) => {
+	console.log(dates.map((date) => date.toString()));
+	expect(received).to.deep.equal(dates.map((date) => date.toJSON()));
+};
+/**
+ * @param {import("../peerjs").DataConnection} dataConnection
+ */
+export const send = (dataConnection) => {
+	for (const date of dates) {
+		dataConnection.send(date);
+	}
+};

+ 16 - 0
e2e/datachannel/dates_as_string.js

@@ -0,0 +1,16 @@
+import { dates } from "../data.js";
+import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
+
+/** @param {unknown[]} received */
+export const check = (received) => {
+	console.log(dates.map((date) => date.toString()));
+	expect(received).to.deep.equal(dates.map((date) => date.toString()));
+};
+/**
+ * @param {import("../peerjs").DataConnection} dataConnection
+ */
+export const send = (dataConnection) => {
+	for (const date of dates) {
+		dataConnection.send(date);
+	}
+};

+ 13 - 0
e2e/datachannel/long_string.js

@@ -0,0 +1,13 @@
+import { long_string } from "../data.js";
+import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
+
+/** @param {unknown[]} received */
+export const check = (received) => {
+	expect(received).to.deep.equal([long_string]);
+};
+/**
+ * @param {import("../peerjs").DataConnection} dataConnection
+ */
+export const send = (dataConnection) => {
+	dataConnection.send(long_string);
+};

+ 2 - 3
e2e/datachannel/numbers.js

@@ -2,15 +2,14 @@ import { numbers } from "../data.js";
 import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
 
 /** @param {unknown[]} received */
-window.check = (received) => {
+export const check = (received) => {
 	expect(received).to.deep.equal(numbers);
 };
 /**
  * @param {import("../peerjs").DataConnection} dataConnection
  */
-window.send = (dataConnection) => {
+export const send = (dataConnection) => {
 	for (const number of numbers) {
 		dataConnection.send(number);
 	}
 };
-window["connect-btn"].disabled = false;

+ 3 - 3
e2e/datachannel/objects.js

@@ -2,15 +2,15 @@ import { commit_data } from "../data.js";
 import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
 
 /** @param {unknown[]} received */
-window.check = (received) => {
+export const check = (received) => {
+	expect(received).to.be.an("array").with.lengthOf(commit_data.length);
 	expect(received).to.deep.equal(commit_data);
 };
 /**
  * @param {import("../peerjs").DataConnection} dataConnection
  */
-window.send = (dataConnection) => {
+export const send = (dataConnection) => {
 	for (const commit of commit_data) {
 		dataConnection.send(commit);
 	}
 };
-window["connect-btn"].disabled = false;

+ 1 - 5
e2e/datachannel/serialization.html

@@ -17,11 +17,7 @@
 		<div id="messages"></div>
 		<div id="result"></div>
 		<div id="error-message"></div>
-		<script src="/dist/peerjs.js"></script>
-		<!--<script src="https://unpkg.com/peerjs@1.4.7/dist/peerjs.min.js"></script>-->
-		<script>
-			import(window.location.search.substring(6));
-		</script>
+		<script src="/dist/peerjs.min.js" type="application/javascript"></script>
 		<script src="serialization.js" type="module"></script>
 	</body>
 </html>

+ 72 - 59
e2e/datachannel/serialization.js

@@ -1,70 +1,83 @@
 /**
- * @type {typeof import("../peerjs").Peer}
+ * @type {typeof import("../../lib/exports.js").Peer}
  */
-const Peer = window.Peer;
+const Peer = window.peerjs.Peer
 
-document.getElementsByTagName("title")[0].innerText =
-	window.location.hash.substring(1);
+const params = new URLSearchParams(document.location.search);
+const testfile = params.get("testfile");
+const serialization = params.get("serialization");
 
-const checkBtn = document.getElementById("check-btn");
-const sendBtn = document.getElementById("send-btn");
-const receiverIdInput = document.getElementById("receiver-id");
-const connectBtn = document.getElementById("connect-btn");
-const messages = document.getElementById("messages");
-const result = document.getElementById("result");
-const errorMessage = document.getElementById("error-message");
+const serializers = {};
 
-const peer = new Peer();
-const received = [];
-/**
- * @type {import("../peerjs").DataConnection}
- */
-let dataConnection;
-peer
-	.once("open", (id) => {
-		messages.textContent = `Your Peer ID: ${id}`;
-	})
-	.once("error", (error) => {
-		errorMessage.textContent = JSON.stringify(error);
-	})
-	.once("connection", (connection) => {
-		dataConnection = connection;
-		dataConnection.on("data", (data) => {
-			console.log(data);
-			received.push(data);
-		});
-		dataConnection.once("close", () => {
-			messages.textContent = "Closed!";
-		});
-	});
+import(`./${testfile}.js`).then(({ check, send }) => {
+	document.getElementsByTagName("title")[0].innerText =
+		window.location.hash.substring(1);
+
+	const checkBtn = document.getElementById("check-btn");
+	const sendBtn = document.getElementById("send-btn");
+	const receiverIdInput = document.getElementById("receiver-id");
+	const connectBtn = document.getElementById("connect-btn");
+	const messages = document.getElementById("messages");
+	const result = document.getElementById("result");
+	const errorMessage = document.getElementById("error-message");
 
-connectBtn.addEventListener("click", () => {
-	const receiverId = receiverIdInput.value;
-	if (receiverId) {
-		dataConnection = peer.connect(receiverId);
-		dataConnection.once("open", () => {
-			messages.textContent = "Connected!";
+	const peer = new Peer({ debug: 3, serializers });
+	const received = [];
+	/**
+	 * @type {import("../../lib/exports.js").DataConnection}
+	 */
+	let dataConnection;
+	peer
+		.once("open", (id) => {
+			messages.textContent = `Your Peer ID: ${id}`;
+		})
+		.once("error", (error) => {
+			errorMessage.textContent = JSON.stringify(error);
+		})
+		.once("connection", (connection) => {
+			dataConnection = connection;
+			dataConnection.on("data", (data) => {
+				console.log(data);
+				received.push(data);
+			});
+			dataConnection.once("close", () => {
+				messages.textContent = "Closed!";
+			});
 		});
-	}
-});
 
-checkBtn.addEventListener("click", async () => {
-	try {
-		window.check(received);
-		result.textContent = "Success!";
-	} catch (e) {
-		result.textContent = "Failed!";
-		errorMessage.textContent = JSON.stringify(e.message);
-	} finally {
-		messages.textContent = "Checked!";
-	}
-});
+	connectBtn.addEventListener("click", () => {
+		const receiverId = receiverIdInput.value;
+		if (receiverId) {
+			dataConnection = peer.connect(receiverId, {
+				reliable: true,
+				serialization,
+			});
+			dataConnection.once("open", () => {
+				messages.textContent = "Connected!";
+			});
+		}
+	});
 
-sendBtn.addEventListener("click", () => {
-	dataConnection.once("error", (err) => {
-		errorMessage.innerText = err.toString();
+	checkBtn.addEventListener("click", async () => {
+		try {
+			console.log(received);
+			check(received);
+			result.textContent = "Success!";
+		} catch (e) {
+			result.textContent = "Failed!";
+			errorMessage.textContent = JSON.stringify(e.message);
+		} finally {
+			messages.textContent = "Checked!";
+		}
+	});
+
+	sendBtn.addEventListener("click", () => {
+		dataConnection.once("error", (err) => {
+			errorMessage.innerText = err.toString();
+		});
+		send(dataConnection);
+		dataConnection.close({ flush: true });
+		messages.textContent = "Sent!";
 	});
-	window.send(dataConnection);
-	dataConnection.close({ flush: true });
-	messages.textContent = "Sent!";
+	window["connect-btn"].disabled = false;
 });

+ 3 - 7
e2e/datachannel/serialization.page.ts

@@ -37,20 +37,16 @@ class SerializationPage {
 		);
 	}
 
-	async open(testFile: string, json: boolean = false) {
+	async open(testFile: string, serialization: string) {
 		await browser.switchWindow("Alice");
 		await browser.url(
-			`/e2e/datachannel/serialization${
-				json ? "_json" : ""
-			}.html?test=${testFile}#Alice`,
+			`/e2e/datachannel/serialization.html?testfile=${testFile}&serialization=${serialization}#Alice`,
 		);
 		await this.connectBtn.waitForEnabled();
 
 		await browser.switchWindow("Bob");
 		await browser.url(
-			`/e2e/datachannel/serialization${
-				json ? "_json" : ""
-			}.html?test=${testFile}#Bob`,
+			`/e2e/datachannel/serialization.html?testfile=${testFile}#Bob`,
 		);
 		await this.connectBtn.waitForEnabled();
 	}

+ 0 - 35
e2e/datachannel/serialization.spec.ts

@@ -1,35 +0,0 @@
-import P from "./serialization.page.js";
-import { browser, expect } from "@wdio/globals";
-
-const serializationTest = (testFile: string) => async () => {
-	await P.open(testFile);
-	await P.waitForMessage("Your Peer ID: ");
-	const bobId = (await P.messages.getText()).split("Your Peer ID: ")[1];
-	await browser.switchWindow("Alice");
-	await P.waitForMessage("Your Peer ID: ");
-	await P.receiverId.setValue(bobId);
-	await P.connectBtn.click();
-	await P.waitForMessage("Connected!");
-	await P.sendBtn.click();
-	await P.waitForMessage("Sent!");
-	await browser.switchWindow("Bob");
-	await P.waitForMessage("Closed!");
-	await P.checkBtn.click();
-	await P.waitForMessage("Checked!");
-
-	await expect(await P.errorMessage.getText()).toBe("");
-	await expect(await P.result.getText()).toBe("Success!");
-};
-describe("DataChannel:Default", () => {
-	beforeAll(async () => {
-		await P.init();
-	});
-	it("should transfer numbers", serializationTest("./numbers.js"));
-	it("should transfer strings", serializationTest("./strings.js"));
-	it("should transfer objects", serializationTest("./objects.js"));
-	it("should transfer arrays", serializationTest("./arrays.js"));
-	it(
-		"should transfer typed arrays / array buffers",
-		serializationTest("./arraybuffers.js"),
-	);
-});

+ 23 - 0
e2e/datachannel/serializationTest.ts

@@ -0,0 +1,23 @@
+import P from "./serialization.page.js";
+import { browser, expect } from "@wdio/globals";
+
+export const serializationTest =
+	(testFile: string, serialization: string) => async () => {
+		await P.open(testFile, serialization);
+		await P.waitForMessage("Your Peer ID: ");
+		const bobId = (await P.messages.getText()).split("Your Peer ID: ")[1];
+		await browser.switchWindow("Alice");
+		await P.waitForMessage("Your Peer ID: ");
+		await P.receiverId.setValue(bobId);
+		await P.connectBtn.click();
+		await P.waitForMessage("Connected!");
+		await P.sendBtn.click();
+		await P.waitForMessage("Sent!");
+		await browser.switchWindow("Bob");
+		await P.waitForMessage("Closed!");
+		await P.checkBtn.click();
+		await P.waitForMessage("Checked!");
+
+		await expect(await P.errorMessage.getText()).toBe("");
+		await expect(await P.result.getText()).toBe("Success!");
+	};

+ 35 - 0
e2e/datachannel/serialization_binary.spec.ts

@@ -0,0 +1,35 @@
+import P from "./serialization.page.js";
+import { serializationTest } from "./serializationTest.js";
+describe("DataChannel:Binary", () => {
+	beforeAll(async () => {
+		await P.init();
+	});
+	it("should transfer numbers", serializationTest("./numbers", "binary"));
+	it("should transfer strings", serializationTest("./strings", "binary"));
+	it(
+		"should transfer long string",
+		serializationTest("./long_string", "binary"),
+	);
+	it("should transfer objects", serializationTest("./objects", "binary"));
+	it("should transfer arrays", serializationTest("./arrays", "binary"));
+	it(
+		"should transfer Dates as strings",
+		serializationTest("./dates_as_string", "binary"),
+	);
+	it(
+		"should transfer ArrayBuffers",
+		serializationTest("./arraybuffers", "binary"),
+	);
+	it(
+		"should transfer TypedArrayView as ArrayBuffer",
+		serializationTest("./TypedArrayView_as_ArrayBuffer", "binary"),
+	);
+	it(
+		"should transfer Uint8Arrays as ArrayBuffer",
+		serializationTest("./Uint8Array_as_ArrayBuffer", "binary"),
+	);
+	it(
+		"should transfer Int32Arrays as ArrayBuffer",
+		serializationTest("./Int32Array_as_ArrayBuffer", "binary"),
+	);
+});

+ 0 - 26
e2e/datachannel/serialization_json.html

@@ -1,26 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-	<head>
-		<meta charset="UTF-8" />
-		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
-		<title></title>
-		<link rel="stylesheet" href="../style.css" />
-	</head>
-	<body>
-		<h1>Serialization</h1>
-		<div id="inputs">
-			<input type="text" id="receiver-id" placeholder="Receiver ID" />
-			<button id="connect-btn" disabled>Connect</button>
-			<button id="send-btn">Send</button>
-			<button id="check-btn">Check</button>
-		</div>
-		<div id="messages"></div>
-		<div id="result"></div>
-		<div id="error-message"></div>
-		<script src="/dist/peerjs.js"></script>
-		<script>
-			import(window.location.search.substring(6));
-		</script>
-		<script src="serialization_json.js" type="module"></script>
-	</body>
-</html>

+ 0 - 70
e2e/datachannel/serialization_json.js

@@ -1,70 +0,0 @@
-/**
- * @type {typeof import('../peerjs').Peer}
- */
-const Peer = window.Peer;
-
-document.getElementsByTagName("title")[0].innerText =
-	window.location.hash.substring(1);
-
-const checkBtn = document.getElementById("check-btn");
-const sendBtn = document.getElementById("send-btn");
-const receiverIdInput = document.getElementById("receiver-id");
-const connectBtn = document.getElementById("connect-btn");
-const messages = document.getElementById("messages");
-const result = document.getElementById("result");
-const errorMessage = document.getElementById("error-message");
-
-const peer = new Peer();
-const received = [];
-/**
- * @type {import('../peerjs').DataConnection}
- */
-let dataConnection;
-peer
-	.once("open", (id) => {
-		messages.textContent = `Your Peer ID: ${id}`;
-	})
-	.once("error", (error) => {
-		errorMessage.textContent = error;
-	})
-	.once("connection", (connection) => {
-		dataConnection = connection;
-		dataConnection.on("data", (data) => {
-			console.log(data);
-			received.push(data);
-		});
-		dataConnection.once("close", () => {
-			messages.textContent = "Closed!";
-		});
-	});
-
-connectBtn.addEventListener("click", () => {
-	const receiverId = receiverIdInput.value;
-	if (receiverId) {
-		dataConnection = peer.connect(receiverId, { serialization: "json" });
-		dataConnection.once("open", () => {
-			messages.textContent = "Connected!";
-		});
-	}
-});
-
-checkBtn.addEventListener("click", async () => {
-	try {
-		window.check(received);
-		result.textContent = "Success!";
-	} catch (e) {
-		result.textContent = "Failed!";
-		errorMessage.textContent = JSON.stringify(e.message);
-	} finally {
-		messages.textContent = "Checked!";
-	}
-});
-
-sendBtn.addEventListener("click", () => {
-	dataConnection.once("error", (err) => {
-		errorMessage.innerText = err.toString();
-	});
-	window.send(dataConnection);
-	dataConnection.close({ flush: true });
-	messages.textContent = "Sent!";
-});

+ 23 - 24
e2e/datachannel/serialization_json.spec.ts

@@ -1,31 +1,30 @@
 import P from "./serialization.page.js";
-import { browser, expect } from "@wdio/globals";
+import { serializationTest } from "./serializationTest.js";
 
-const serializationTest = (testFile: string) => async () => {
-	await P.open(testFile, true);
-	await P.waitForMessage("Your Peer ID: ");
-	const bobId = (await P.messages.getText()).split("Your Peer ID: ")[1];
-	await browser.switchWindow("Alice");
-	await P.waitForMessage("Your Peer ID: ");
-	await P.receiverId.setValue(bobId);
-	await P.connectBtn.click();
-	await P.waitForMessage("Connected!");
-	await P.sendBtn.click();
-	await P.waitForMessage("Sent!");
-	await browser.switchWindow("Bob");
-	await P.waitForMessage("Closed!");
-	await P.checkBtn.click();
-	await P.waitForMessage("Checked!");
-
-	await expect(await P.errorMessage.getText()).toBe("");
-	await expect(await P.result.getText()).toBe("Success!");
-};
 describe("DataChannel:JSON", () => {
 	beforeAll(async () => {
 		await P.init();
 	});
-	it("should transfer numbers", serializationTest("./numbers.js"));
-	it("should transfer strings", serializationTest("./strings_json.js"));
-	it("should transfer objects", serializationTest("./objects.js"));
-	it("should transfer arrays", serializationTest("./arrays_json.js"));
+	it("should transfer numbers", serializationTest("./numbers", "json"));
+	it("should transfer strings", serializationTest("./strings", "json"));
+	// it("should transfer long string", serializationTest("./long_string", "json"));
+	it("should transfer objects", serializationTest("./objects", "json"));
+	it(
+		"should transfer arrays (no chunks)",
+		serializationTest("./arrays_unchunked", "json"),
+	);
+	it(
+		"should transfer Dates as strings",
+		serializationTest("./dates_as_json_string", "json"),
+	);
+	// it("should transfer ArrayBuffers", serializationTest("./arraybuffers", "json"));
+	// it("should transfer TypedArrayView", serializationTest("./typed_array_view", "json"));
+	// it(
+	// 	"should transfer Uint8Arrays",
+	// 	serializationTest("./Uint8Array", "json"),
+	// );
+	// it(
+	// 	"should transfer Int32Arrays",
+	// 	serializationTest("./Int32Array", "json"),
+	// );
 });

+ 4 - 6
e2e/datachannel/strings.js

@@ -1,17 +1,15 @@
-import { strings, long_string } from "../data.js";
+import { strings } from "../data.js";
 import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
 
 /** @param {unknown[]} received */
-window.check = (received) => {
-	expect(received).to.deep.equal([long_string, ...strings]);
+export const check = (received) => {
+	expect(received).to.deep.equal(strings);
 };
 /**
  * @param {import("../peerjs").DataConnection} dataConnection
  */
-window.send = (dataConnection) => {
-	dataConnection.send(long_string);
+export const send = (dataConnection) => {
 	for (const string of strings) {
 		dataConnection.send(string);
 	}
 };
-window["connect-btn"].disabled = false;

+ 0 - 19
e2e/datachannel/strings_json.js

@@ -1,19 +0,0 @@
-/**
- * JSON transfer does not chunk, large_string is too large to send
- */
-import { strings, long_string } from "../data.js";
-import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
-
-/** @param {unknown[]} received */
-window.check = (received) => {
-	expect(received).to.deep.equal(strings);
-};
-/**
- * @param {import("../peerjs").DataConnection} dataConnection
- */
-window.send = (dataConnection) => {
-	for (const string of strings) {
-		dataConnection.send(string);
-	}
-};
-window["connect-btn"].disabled = false;

+ 17 - 0
e2e/datachannel/typed_array_view.js

@@ -0,0 +1,17 @@
+import { typed_array_view } from "../data.js";
+import { expect } from "https://esm.sh/v126/chai@4.3.7/X-dHMvZXhwZWN0/es2021/chai.bundle.mjs";
+
+/** @param {unknown[]} received */
+export const check = (received) => {
+	const received_typed_array_view = received[0];
+	expect(received_typed_array_view).to.deep.equal(typed_array_view);
+	for (const [i, v] of received_typed_array_view.entries()) {
+		expect(v).to.deep.equal(typed_array_view[i]);
+	}
+};
+/**
+ * @param {import("../peerjs").DataConnection} dataConnection
+ */
+export const send = (dataConnection) => {
+	dataConnection.send(typed_array_view);
+};

+ 1 - 1
e2e/mediachannel/close.html

@@ -33,6 +33,6 @@
 		<div id="error-message"></div>
 		<video></video>
 		<script src="/dist/peerjs.js"></script>
-		<script src="close.js" type="module"></script>
+		<script src="close.js" type="application/javascript"></script>
 	</body>
 </html>

+ 2 - 2
e2e/mediachannel/close.js

@@ -1,7 +1,7 @@
 /**
- * @type {typeof import("../peerjs").Peer}
+ * @type {typeof import("../..").Peer}
  */
-const Peer = window.Peer;
+const Peer = window.peerjs.Peer;
 
 document.getElementsByTagName("title")[0].innerText =
 	window.location.hash.substring(1);

+ 1 - 1
e2e/mediachannel/close.spec.ts

@@ -1,7 +1,7 @@
 import P from "./close.page.js";
 import { browser } from "@wdio/globals";
 
-fdescribe("MediaStream", () => {
+describe("MediaStream", () => {
 	beforeAll(async () => {
 		await P.init();
 	});

+ 36 - 24
e2e/wdio.bstack.conf.ts

@@ -20,7 +20,25 @@ export const config: WebdriverIO.Config = {
 				"bstack:options": {
 					os: "Windows",
 					osVersion: "11",
-					browserVersion: "81",
+					browserVersion: "83",
+					localIdentifier: process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
+				},
+			},
+			{
+				browserName: "Chrome",
+				"bstack:options": {
+					os: "Windows",
+					osVersion: "11",
+					browserVersion: "83",
+					localIdentifier: process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
+				},
+			},
+			{
+				browserName: "Chrome",
+				"bstack:options": {
+					browserVersion: "latest",
+					os: "Windows",
+					osVersion: "11",
 					localIdentifier: process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
 				},
 			},
@@ -34,38 +52,32 @@ export const config: WebdriverIO.Config = {
 				},
 			},
 			{
-				browserName: "Safari",
+				browserName: "Firefox",
 				"bstack:options": {
-					browserVersion: "latest",
+					browserVersion: "105",
 					os: "OS X",
-					osVersion: "Big Sur",
+					osVersion: "Ventura",
 					localIdentifier: process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
 				},
 			},
 			// {
-			// 	browserName: 'Safari',
-			// 	'bstack:options': {
-			// 		browserVersion: 'latest',
-			// 		os: 'OS X',
-			// 		osVersion: 'Monterey'
-			// 	}
+			//     browserName: "Safari",
+			//     "bstack:options": {
+			//         browserVersion: "latest",
+			//         os: "OS X",
+			//         osVersion: "Monterey",
+			//         localIdentifier: process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
+			//     },
 			// },
 			// {
-			// 	browserName: 'Chrome',
-			// 	'bstack:options': {
-			// 		browserVersion: 'latest',
-			// 		os: 'Windows',
-			// 		osVersion: '11'
-			// 	}
+			//     browserName: 'Safari',
+			//     'bstack:options': {
+			//         browserVersion: 'latest',
+			//         os: 'OS X',
+			//         osVersion: 'Ventura',
+			//         localIdentifier: process.env.BROWSERSTACK_LOCAL_IDENTIFIER,
+			//     }
 			// },
-			// {
-			// 	browserName: 'Firefox',
-			// 	'bstack:options': {
-			// 		browserVersion: 'latest',
-			// 		os: 'OS X',
-			// 		osVersion: 'Ventura'
-			// 	}
-			// }
 		],
 	},
 };

+ 2 - 2
e2e/wdio.local.conf.ts

@@ -8,8 +8,8 @@ export const config: WebdriverIO.Config = {
 		capabilities: [
 			{
 				browserName: "chrome",
-				"wdio:devtoolsOptions": {
-					headless: true,
+				"goog:chromeOptions": {
+					args: ["headless", "disable-gpu"],
 				},
 			},
 			{