vitest-environment-mongodb 1.0.0 → 1.0.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
@@ -71,4 +71,6 @@ test("should create a user", async () => {
71
71
 
72
72
  - `mongoUrlEnvName` (string): The name of the environment variable that will contain the MongoDB connection string. Default is `MONGO_CONNECTION_STRING`.
73
73
  - `replicaSet` (boolean): Whether to use a replica set. Default is `false`.
74
- And any other options that are supported by `mongodb-memory-server` package.
74
+ - `serverOptions` (MongoMemoryServerOpts | MongoMemoryReplSetOpts): An options object
75
+ that will passed through to the `mongodb-memory-server` package. Be sure to use the
76
+ options for the server type you are using, either `MongoMemoryReplSetOpts` when `replicaSet=true` or `MongoMemoryServerOpts` for `replicaSet=false`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest-environment-mongodb",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Sets up a MongoDB memory-server environment for testing with Vitest.",
5
5
  "main": "dist/mongodb-environment.js",
6
6
  "scripts": {
@@ -1,36 +0,0 @@
1
- name: Release
2
- on:
3
- push:
4
- branches:
5
- - main
6
-
7
- permissions:
8
- contents: read # for checkout
9
-
10
- jobs:
11
- release:
12
- name: Release
13
- runs-on: ubuntu-latest
14
- permissions:
15
- contents: write # to be able to publish a GitHub release
16
- issues: write # to be able to comment on released issues
17
- pull-requests: write # to be able to comment on released pull requests
18
- id-token: write # to enable use of OIDC for npm provenance
19
- steps:
20
- - name: Checkout
21
- uses: actions/checkout@v4
22
- with:
23
- fetch-depth: 0
24
- - name: Setup Node.js
25
- uses: actions/setup-node@v4
26
- with:
27
- node-version: "lts/*"
28
- - name: Install dependencies
29
- run: npm clean-install
30
- - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
31
- run: npm audit signatures
32
- - name: Release
33
- env:
34
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
36
- run: npx semantic-release
@@ -1,45 +0,0 @@
1
- import type { Environment } from "vitest/environments"
2
- import { MongoMemoryReplSet, MongoMemoryServer } from "mongodb-memory-server"
3
-
4
- type Options =
5
- | {
6
- replicaSet?: false
7
- mongoUrlEnvName?: string
8
- serverOptions?: NonNullable<
9
- Parameters<(typeof MongoMemoryServer)["create"]>[0]
10
- >
11
- }
12
- | {
13
- replicaSet: true
14
- mongoUrlEnvName?: string
15
- serverOptions?: NonNullable<
16
- Parameters<(typeof MongoMemoryReplSet)["create"]>[0]
17
- >
18
- }
19
-
20
- export default <Environment>{
21
- name: "mongodb",
22
- transformMode: "ssr",
23
- async setup(_, options?: Options) {
24
- // parse out options
25
- const isReplicaSet = options?.replicaSet
26
- const serverOptions = options?.serverOptions ?? {}
27
- const mongoUrlEnvName =
28
- options?.mongoUrlEnvName ?? "MONGO_CONNECTION_STRING"
29
-
30
- // create server
31
- const mongoServer = isReplicaSet
32
- ? await MongoMemoryServer.create(serverOptions)
33
- : await MongoMemoryReplSet.create(serverOptions)
34
-
35
- // put the connection string in the environment
36
- process.env[mongoUrlEnvName] = mongoServer.getUri()
37
-
38
- return {
39
- async teardown() {
40
- // stop the server
41
- await mongoServer.stop()
42
- },
43
- }
44
- },
45
- }
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "NodeNext",
4
- "moduleResolution": "nodenext",
5
- "target": "esnext",
6
- "strict": true,
7
- "outDir": "./dist",
8
- "declaration": true,
9
- "skipLibCheck": true
10
- },
11
- "include": ["src"]
12
- }