vitest-environment-mongodb 1.0.0 → 1.0.1
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 +1 -1
- package/.github/workflows/release.yml +0 -36
- package/src/mongodb-environment.ts +0 -45
- package/tsconfig.json +0 -12
package/package.json
CHANGED
|
@@ -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
|
-
}
|