Registry / testing / jest-environment-mysql

jest-environment-mysql

JSON →
library1.2.17jsnpmunverified

A custom Jest environment that deploys a local MySQL 5.7 server on OSX x64, starting once before all tests and stopping after. Version 1.2.17 is the latest. Key differentiator: no external Docker or service dependencies—spins up MySQL natively. OSX-only, requires peer dependencies for platform-specific binaries. Ideal for integration testing against a real MySQL instance without manual setup.

npm install jest-environment-mysql
INSTALL
IMPORT
SIG · JEST-ENVIRONMENT-M
J
jest-environment-mysql
testingjavascriptv1.2.17
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

globalSetup
module.exports = require('jest-environment-mysql/lib/globalSetup')
import { globalSetup } from 'jest-environment-mysql'
Jest config expects CommonJS module export. Import path is lib/ subdirectory.
globalTeardown
module.exports = require('jest-environment-mysql/lib/globalTeardown')
import { globalTeardown } from 'jest-environment-mysql'
Similar to globalSetup; must use require for Jest config.
TestEnvironment
const TestEnvironment = require('jest-environment-mysql')
import TestEnvironment from 'jest-environment-mysql'
The default export is the environment class, but it's not typically imported directly—Jest uses it internally.

Configures Jest to use the MySQL environment by setting globalSetup and globalTeardown paths.

// jest.config.js module.exports = { globalSetup: 'jest-environment-mysql/lib/globalSetup', globalTeardown: 'jest-environment-mysql/lib/globalTeardown' };
Debug
Known issues
gotchaOSX-only support: package only works on OSX x64. No Windows or Linux support.
fix
Use Docker or a different Jest environment for other OS.
affects: >=0.0.0
deprecatedPeer dependencies reference mysql-server-8-* but actual server deployed is MySQL 5.7.
fix
Install mysql-server-5.7-osx-x64 (not available on npm) or use the correct peer packages.
affects: >=1.0.0
gotchaGlobal setup/teardown must be required via lib/ subpath, not top-level package.
fix
Use 'jest-environment-mysql/lib/globalSetup' and 'jest-environment-mysql/lib/globalTeardown' in Jest config.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'mysql-server-5.7-osx-x64'
Peer dependency not installed or OS not supported.
fix
Run 'npm install --save-dev mysql-server-5.7-osx-x64' (if available) or switch to supported OS.
Upgrade
Version history
1.2.17latest on npm
Audit
Dependencies
mysql-server-8-osx-x64optionalPeer dependency to run MySQL server on OSX (specified but likely for v8; actual server is 5.7)
mysql-server-8-win-x64optionalPeer dependency for Windows (not supported; placeholder)
mysql-server-5.7-lin-x64optionalPeer dependency for Linux (not supported; placeholder)
Agent activity
10 hits · last 30 days
node
8
Amazon
1
Resources
jest-environment-mysql — npm install jest-environment-mysql · libregistry