@friggframework/test 2.0.0--canary.682.451c957.0 → 2.0.0--canary.666.89f6545.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,26 @@
1
+ // @friggframework/test is a runtime dependency of @friggframework/devtools,
2
+ // so it is installed in every Frigg app. TestMongo downloads its pinned
3
+ // MongoDB binary on first use; no MongoDB package it depends on may also
4
+ // download one at install time (mongodb-memory-server's postinstall did,
5
+ // and fetched the library default rather than the pinned version).
6
+ describe('@friggframework/test install footprint', () => {
7
+ const { dependencies } = require('./package.json');
8
+ const mongoDependencies = Object.keys(dependencies).filter((name) =>
9
+ name.includes('mongo')
10
+ );
11
+
12
+ it('uses a MongoDB in-memory server package', () => {
13
+ expect(mongoDependencies).not.toEqual([]);
14
+ });
15
+
16
+ it.each(mongoDependencies)('%s has no install-time scripts', (name) => {
17
+ const manifest = require(require.resolve(`${name}/package.json`, {
18
+ paths: [__dirname],
19
+ }));
20
+ const scripts = manifest.scripts || {};
21
+
22
+ expect(
23
+ ['preinstall', 'install', 'postinstall'].filter((hook) => scripts[hook])
24
+ ).toEqual([]);
25
+ });
26
+ });
@@ -0,0 +1,24 @@
1
+ const net = require('node:net');
2
+ const { TestMongo } = require('./mongodb');
3
+
4
+ // Opt-in DB test (`npm run test:db`): proves the pinned MongoDB binary
5
+ // downloads and starts on the CI image (Ubuntu 24.04 has no OpenSSL 1.1,
6
+ // which the old 5.0.x default needed).
7
+ describe('TestMongo', () => {
8
+ const testMongo = new TestMongo();
9
+
10
+ beforeAll(() => testMongo.start(), 120_000);
11
+ afterAll(() => testMongo.stop());
12
+
13
+ it('starts mongod and exports a reachable MONGO_URI', async () => {
14
+ const { hostname, port } = new URL(process.env.MONGO_URI);
15
+
16
+ await new Promise((resolve, reject) => {
17
+ const socket = net.connect(Number(port), hostname, () => {
18
+ socket.end();
19
+ resolve();
20
+ });
21
+ socket.on('error', reject);
22
+ });
23
+ });
24
+ });
package/mongodb.js CHANGED
@@ -1,11 +1,20 @@
1
- const { MongoMemoryServer } = require('mongodb-memory-server');
1
+ const { MongoMemoryServer } = require('mongodb-memory-server-core');
2
+
3
+ // Pin the MongoDB binary instead of relying on the library default. The old
4
+ // default (5.0.19) only ships Ubuntu 20.04 builds that link against OpenSSL
5
+ // 1.1 (libcrypto.so.1.1), which Ubuntu 24.04 (GitHub's ubuntu-latest) no
6
+ // longer ships, so the server failed to start in CI. MongoDB 8.0 has native
7
+ // Ubuntu 24.04 builds. MONGOMS_VERSION still overrides this for local use.
8
+ const MONGODB_BINARY_VERSION = process.env.MONGOMS_VERSION || '8.0.17';
2
9
 
3
10
  class TestMongo {
4
11
  #mongoServer;
5
12
 
6
13
  // Start the in-memory mongo instance and set env variable for the app to use in its connection.
7
14
  async start() {
8
- this.#mongoServer = await MongoMemoryServer.create();
15
+ this.#mongoServer = await MongoMemoryServer.create({
16
+ binary: { version: MONGODB_BINARY_VERSION },
17
+ });
9
18
  process.env.MONGO_URI = this.#mongoServer.getUri();
10
19
  console.log('Started in memory mongo server', process.env.MONGO_URI);
11
20
  }
@@ -19,4 +28,5 @@ class TestMongo {
19
28
 
20
29
  module.exports = {
21
30
  TestMongo,
31
+ MONGODB_BINARY_VERSION,
22
32
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/test",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.682.451c957.0",
4
+ "version": "2.0.0--canary.666.89f6545.0",
5
5
  "dependencies": {
6
6
  "@babel/eslint-parser": "^7.18.9",
7
7
  "eslint": "^8.22.0",
@@ -11,18 +11,19 @@
11
11
  "eslint-plugin-no-only-tests": "^3.0.0",
12
12
  "eslint-plugin-yaml": "^0.5.0",
13
13
  "jest-runner-groups": "^2.2.0",
14
- "mongodb-memory-server": "^8.9.0",
14
+ "mongodb-memory-server-core": "^11.3.0",
15
15
  "open": "^8.4.2"
16
16
  },
17
17
  "devDependencies": {
18
- "@friggframework/eslint-config": "2.0.0--canary.682.451c957.0",
19
- "@friggframework/prettier-config": "2.0.0--canary.682.451c957.0",
18
+ "@friggframework/eslint-config": "2.0.0--canary.666.89f6545.0",
19
+ "@friggframework/prettier-config": "2.0.0--canary.666.89f6545.0",
20
20
  "jest": "^29.7.0",
21
21
  "prettier": "^2.7.1"
22
22
  },
23
23
  "scripts": {
24
24
  "lint:fix": "prettier --write --loglevel error . && eslint . --fix",
25
- "test": "jest --passWithNoTests # TODO"
25
+ "test": "jest --passWithNoTests --testPathIgnorePatterns '\\.db\\.test\\.js$' # TODO",
26
+ "test:db": "jest --testMatch '**/*.db.test.js'"
26
27
  },
27
28
  "author": "",
28
29
  "license": "MIT",
@@ -39,5 +40,5 @@
39
40
  "publishConfig": {
40
41
  "access": "public"
41
42
  },
42
- "gitHead": "451c957b188ef7010eecc3c99e0f7ed91e506825"
43
+ "gitHead": "89f6545362623128362b730cb02b286c8308c66e"
43
44
  }