@rpcbase/test 0.120.0 → 0.121.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.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rpcbase/test",
3
- "version": "0.120.0",
3
+ "version": "0.121.0",
4
+ "type": "module",
4
5
  "bin": {
5
6
  "rb-test": "./src/cli.js"
6
7
  },
@@ -32,8 +33,9 @@
32
33
  }
33
34
  },
34
35
  "dependencies": {
35
- "@playwright/test": "1.52.0",
36
- "lodash": "4.17.21"
36
+ "@playwright/test": "1.53.1",
37
+ "lodash": "4.17.21",
38
+ "mongoose": "8.16.1"
37
39
  },
38
40
  "devDependencies": {}
39
41
  }
@@ -0,0 +1,18 @@
1
+ import mongoose from "mongoose"
2
+
3
+ export async function clearDatabase(dbName) {
4
+ const { MONGO_PORT, APP_NAME } = process.env
5
+
6
+ const connectionString = `mongodb://localhost:${MONGO_PORT}/${APP_NAME}-${dbName}`
7
+
8
+ console.log("will clear DB:", connectionString)
9
+
10
+ const connection = await mongoose
11
+ .createConnection(connectionString)
12
+ .asPromise()
13
+
14
+ // Drop the database
15
+ await connection.dropDatabase()
16
+
17
+ await connection.close()
18
+ }
package/src/cli.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
- const { spawn } = require("child_process");
3
- const fs = require("fs");
4
- const path = require("path");
2
+
3
+ import { spawn } from "child_process"
4
+ import fs from "fs"
5
+ import path from "path"
5
6
 
6
7
  const isAider = process.env.IS_AIDER === "yes";
7
8
 
@@ -1,11 +1,11 @@
1
- const fs = require("fs")
2
- const {cpus} = require("os")
3
- const _merge = require("lodash/merge")
4
- const {defineConfig, devices} = require("@playwright/test")
1
+ import fs from "fs"
2
+ import { cpus } from "os"
3
+ import _ from "lodash"
4
+ import { defineConfig, devices } from "@playwright/test"
5
5
 
6
6
 
7
7
  function mergeConfig(base, override) {
8
- return _merge({}, base, override);
8
+ return _.merge({}, base, override);
9
9
  }
10
10
 
11
11
  const hasPassedAllPreviousTests = (data) => {
@@ -65,8 +65,8 @@ const isHeadless = () => {
65
65
  }
66
66
 
67
67
 
68
- // https://playwright.dev/docs/test-configuration.
69
- module.exports = function(config) {
68
+ // https://playwright.dev/docs/test-configuration
69
+ export default function(config) {
70
70
 
71
71
  const baseConfig = {
72
72
  globalSetup: ["./spec/helpers/globalSetup.ts"],
package/src/index.js CHANGED
@@ -1,3 +1,2 @@
1
- const defineConfig = require("./defineConfig")
2
-
3
- module.exports = {defineConfig}
1
+ // export * from "./defineConfig"
2
+ export * from "./clearDatabase"