Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node integration test enviroment #5241

Merged
merged 4 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions integration-tests/environments/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
"electron-builder": "^22.10.5",
"mocha-github-actions-reporter": "^0.2.3",
"mocha-junit-reporter": "^2.0.0",
"mocha-remote-cli": "^1.5.0"
"mocha-remote-cli": "^1.6.0"
},
"dependencies": {
"@realm/integration-tests": "*",
"fs-extra": "^9.1.0",
"mocha": "^8.3.2",
"mocha-remote-client": "^1.5.0",
"mocha-remote-client": "^1.6.0",
"@realm/app-importer": "*"
},
"build": {
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/environments/node/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"env": {
"mocha": true,
"node": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2022
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,34 @@
//
////////////////////////////////////////////////////////////////////////////

const os = require("os");
const { Client } = require("mocha-remote-client");
import os from "node:os";
import { Client } from "mocha-remote-client";
import fs from "fs-extra";
import path from "path";

global.client = new Client({
const client = new Client({
title: `Node.js v${process.versions.node} on ${os.platform()}`,
tests(context) {
async tests(context) {
console.log("Test is being called!");
// Exposing the Realm constructor as a global
global.fs = require("fs-extra");
global.path = require("path");
global.fs = fs;
global.path = path;
global.environment = { ...context, node: true };

// Add the integration test suite (in TypeScript)
require("ts-node/register/transpile-only");
require("@realm/integration-tests");
// Add the integration test suite
await import("@realm/integration-tests");
console.log("integration tests loaded");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed console.logs here and in the updated mocha-client. Do we want to keep those in, or were they just for testing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah - good catch. They need to go 🙂

// Load the Node.js specific part of the integration tests
require("@realm/integration-tests/src/node");
await import("@realm/integration-tests/node");
console.log("node integration tests loaded");
},
});

client.on("error", (err) => {
console.error("Failure from Mocha Remote Client:", err);
process.exitCode = 1;
});

global.client = client;

// TODO: Setup a watch to re-run when the tests change
Loading