mysql-memory-server 1.4.1 → 1.4.2

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/README.md CHANGED
@@ -13,15 +13,20 @@ Download with your package manager of choice. The package name is `mysql-memory-
13
13
  - Node.js 16.6.0 and newer
14
14
  - macOS 13+, Windows, or Linux (This package is only tested on Ubuntu 20.04, 22.04, 24.04, and Fedora 40. Other Linux distributions may or may not work at this time.)
15
15
 
16
- Windows only requirements:
16
+ #### Requirements for downloaded MySQL versions
17
+
18
+ The following requirements only apply if you intend to have `mysql-memory-server` download a version of MySQL to use instead of using an already installed version of MySQL on the system:
19
+
20
+ Requirements for Windows:
17
21
  - `Microsoft Visual C++ 2019 Redistributable Package` needs to be installed
18
22
 
19
- Linux only requirements:
23
+ Requirements for Linux:
20
24
  - The `libaio1` or `libaio1t64` package needs to be installed
21
25
  - If `libaio1` is not available but `libaio1t64` is, the `ldconfig` command needs to be available to run
22
- - The `tar` package needs to be installed if you want to use MySQL versions that aren't system installed
26
+ - The `tar` package needs to be installed
27
+
28
+ #### Currently supported MySQL versions
23
29
 
24
- Currently supported MySQL versions:
25
30
  - If using the system installed MySQL server: 8.0.20 and newer
26
31
  - If not using the system installed MySQL server: 8.0.39, 8.1.0, 8.2.0, 8.3.0, 8.4.2, 9.0.1
27
32
 
@@ -31,15 +36,26 @@ Currently supported MySQL versions:
31
36
  import { createDB } from 'mysql-memory-server';
32
37
  import sql from 'mysql2/promise'
33
38
 
34
- // Create a new database
39
+ // Create a new database with default options
35
40
  const db = await createDB()
36
41
 
42
+ //OR
43
+
44
+ //Create a new database with custom options set
45
+ const db = await createDB({
46
+ // see Options for the options you can use in this object and their default values
47
+ // for example:
48
+ version: '8.4.x'
49
+ })
50
+
37
51
  // Connect to the new database with the port provided
52
+ // The database is initialized with an empty password so use an empty string for the password
38
53
  const connection = await sql.createConnection({
39
54
  host: '127.0.0.1',
40
55
  user: db.username,
41
56
  port: db.port,
42
57
  database: db.dbName
58
+ password: ''
43
59
  })
44
60
 
45
61
  // Run your queries here
@@ -52,6 +68,9 @@ await connection.end()
52
68
  await db.stop()
53
69
  ```
54
70
 
71
+ MySQL database initialization can take some time. If you run into a "Timeout exceeded" error with your tests, the timeout should be extended.
72
+ If using Jest, information about how to do this can be found here: https://jestjs.io/docs/jest-object#jestsettimeouttimeout
73
+
55
74
  ## Documentation
56
75
 
57
76
  ##### `createDB(options: ServerOptions): Promise<MySQLDB>`
@@ -393,7 +393,7 @@ _Executor_instances = new WeakSet(), _Executor_execute = function _Executor_exec
393
393
  }
394
394
  }
395
395
  catch (error) {
396
- if (String(error) === 'Error: Lock file is already being held') {
396
+ if (String(error).includes('Lock file is already being held')) {
397
397
  this.logger.log('Waiting for lock for libaio copy');
398
398
  await (0, FileLock_1.waitForLock)(copyPath, options);
399
399
  this.logger.log('Lock is gone for libaio copy');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql-memory-server",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "Spin up an ephemeral MySQL database from your JavaScript code",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "@babel/preset-env": "^7.25.4",
28
28
  "@babel/preset-typescript": "^7.24.7",
29
29
  "@types/adm-zip": "^0.5.5",
30
- "@types/node": "^22.5.0",
30
+ "@types/node": "^22.5.4",
31
31
  "@types/proper-lockfile": "^4.1.4",
32
32
  "@types/semver": "^7.5.8",
33
33
  "babel-jest": "^29.7.0",
@@ -36,7 +36,7 @@
36
36
  "typescript": "^5.5.4"
37
37
  },
38
38
  "dependencies": {
39
- "adm-zip": "^0.5.15",
39
+ "adm-zip": "^0.5.16",
40
40
  "proper-lockfile": "^4.1.2",
41
41
  "semver": "^7.6.3"
42
42
  },