@@ -36,15 +36,27 @@ running, and then:
36
36
docker ps
37
37
```
38
38
39
- The output resembles:
39
+ The output resembles:
40
40
41
- ``` shell
42
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43
- ef70cce38f26 mongo " /usr/local/bin/runn…" 29 hours ago Up 29 hours (healthy) 127.0.0.1:63201-> 27017/tcp mongodb-test
44
- ```
41
+ ``` text
42
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43
+ ef70cce38f26 mongo "/usr/local/bin/runn…" 29 hours ago Up 29 hours (healthy) 127.0.0.1:63201->27017/tcp mongodb-test
44
+ ```
45
+
46
+ You may note the actual port is different than ` 27017 ` , if something else is already running on
47
+ ` 27017 ` on your machine. Note the port next to the IP address for running the tests. Alternately, you can get just
48
+ the port info for your container using the following command:
45
49
46
- You may note the actual port is different than ` 27017 ` , if something else is already running on
47
- ` 27017 ` on your machine. Note the port next to the IP address for running the tests.
50
+ ``` shell
51
+ docker port mongodb-test
52
+ ```
53
+
54
+ The output resembles:
55
+
56
+ ``` text
57
+ 27017/tcp -> 0.0.0.0:27017
58
+ 27017/tcp -> [::]:27017
59
+ ```
48
60
49
61
### Create a .env file
50
62
@@ -103,40 +115,18 @@ In the above command:
103
115
104
116
You can run all the tests in a given test suite (file).
105
117
106
- From the ` /tests ` directory, run:
118
+ From the ` /mongosh ` directory, run:
107
119
108
120
```
109
- export $(xargs < ../.env) && jest -t '<text string from the 'describe' block you want to run>' --runInBand
121
+ npm test -- -t '<text string from the 'describe() ' block you want to run>'
110
122
```
111
123
112
- In the above command:
113
-
114
- - ` export $(xargs < ../.env) ` is Linux flag to make the contents of the ` .env `
115
- file available to the test suite
116
- - ` jest ` is the command to run the test suite
117
- - ` -t '<text string from the 'describe' block you want to run>' ` is the way to
118
- specify to run all tests in test suite, which in this test, is a single file
119
- - ` --runInBand ` is a flag that specifies only running one test at a time
120
- to avoid collisions when creating/editing/dropping indexes. Otherwise, Jest
121
- defaults to running tests in parallel.
122
-
123
124
#### Run Individual Tests from the command line
124
125
125
126
You can run a single test within a given test suite (file).
126
127
127
- From the ` /tests ` directory, run:
128
+ From the ` /mongosh ` directory, run:
128
129
129
130
```
130
- export $(xargs < ../.env) && jest -t '<text string from the 'it' block of the test you want to run>'
131
+ npm test -- -t '<text string from the 'it() ' block you want to run>'
131
132
```
132
-
133
- In the above command:
134
-
135
- - ` export $(xargs < ../.env) ` is Linux flag to make the contents of the ` .env `
136
- file available to the test suite
137
- - ` jest ` is the command to run the test suite
138
- - ` -t '<text string from the 'it' block of the test you want to run>' ` is the
139
- way to specify to run a single test matching your text
140
-
141
- Since you are only running a single test, there is no chance of colliding
142
- with the other tests, so the ` --runInBand ` flag isn't needed.
0 commit comments