Skip to content

Commit 0546aa7

Browse files
committed
Add testWindows script target for running tests on Windows
1 parent 54cc80d commit 0546aa7

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
"async": "~0.9.0"
4242
},
4343
"scripts": {
44-
"test": "node_modules/mocha/bin/mocha -R spec --timeout 10000 test/*.js"
44+
"test": "mocha -R spec --timeout 10000 test/*.js",
45+
"testWindows": "mocha -R spec --timeout 0 test\\*.js"
4546
},
4647
"engineStrict": true,
4748
"engines": {

test/README.md

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ limitations under the License.
1818
The node-oracledb test suite uses 'mocha', 'should' and 'async'.
1919
See LICENSE.md for relevant licenses.
2020

21-
## Running the complete test suite
21+
## 1. Preparations for running tests
2222

23-
### 1. Create a working directory
23+
### 1.1 Create a working directory
2424

2525
```
26-
mkdir <some-directory>
26+
mkdir <some-directory>
2727
cd <some-directory>
2828
```
2929

30-
### 2. Install node-oracledb
30+
### 1.2 Install node-oracledb
3131

3232
See [INSTALL](https://github.com/oracle/node-oracledb/blob/master/INSTALL.md)
3333
for installation requirements and more details.
@@ -45,22 +45,26 @@ git clone https://github.com/oracle/node-oracledb.git
4545
npm install node-oracledb
4646
```
4747

48-
### 3. Install dependent modules
48+
### 1.3 Install test-dependent modules
4949

50-
The test suite uses [mocha](https://www.npmjs.com/package/mocha), [async](https://www.npmjs.com/package/async) and [should](https://www.npmjs.com/package/should). These need to be installed separately.
50+
The test suite uses [mocha](https://www.npmjs.com/package/mocha),
51+
[async](https://www.npmjs.com/package/async) and
52+
[should](https://www.npmjs.com/package/should).
5153

5254
```
53-
cd <some-directory>/node_modules/oracledb
54-
npm install mocha should async
55+
cd <some-directory>/node_modules/oracledb
56+
npm install
5557
```
5658

57-
Note: these are listed in `devDependencies` in `package.json` so `npm
58-
install` will install them when executed inside a node-oracledb
59-
package directory.
59+
Note: Running `npm install` within oracledb/ directory will recompile
60+
oracledb module and install all its dependent modules which are listed
61+
in `devDependencies` field in `package.json` file. So 'mocha', 'async'
62+
and 'should' modules are installed by this command.
6063

61-
### 4. Database credentials
64+
### 1.4 Configure Database credentials
6265

63-
The database credentials for node-oracledb test suite are defined in dbConfig.js file. You can set the credentials via environment variables or dbConfig.js file.
66+
The database credentials for node-oracledb test suite are defined in dbConfig.js file.
67+
You can set the credentials via environment variables or dbConfig.js file.
6468
Change the credentials to a user who has privileges to connect and create tables.
6569

6670
```
@@ -82,31 +86,42 @@ have been appropriately configured. See
8286
[Documentation for External Authentication](https://github.com/oracle/node-oracledb/blob/master/doc/api.md#extauth)
8387
for more details.
8488

85-
### 5. Run test suite
89+
## 2. Running tests
8690

87-
All tests can be run with:
91+
### 2.1 Run the complete test suite
92+
93+
#### On Unix-like systems
8894

8995
```
90-
cd <some-directory>/node_modules/oracledb
96+
cd <some-directory>/node_modules/oracledb
9197
npm test
9298
```
9399

94-
This calls the `test` script defined in `<some-directory>/node_modules/oracledb/package.json`.
95-
If `mocha` is not in the directory specified in `package.json`, for example if you have installed it globally, then edit `package.json` and change the path.
100+
This calls the `test` script defined in `oracledb/package.json`.
101+
102+
#### On Windows
103+
104+
```
105+
cd <some-directory>/node_modules/oracledb
106+
npm run-script testWindows
107+
```
96108

97-
## Running a single test
109+
This calls the `testWindows` script defined in `oracledb/package.json`.
110+
See [npm scripts](https://docs.npmjs.com/misc/scripts) for more infomation
111+
about how npm handles "scripts" field of package.json.
98112

99-
Individual tests can be run using:
113+
### 2.2 Run specified test(s)
100114

101115
```
102-
cd <some-directory>/node_modules/oracledb
103-
../mocha/bin/mocha test/<test-name>
116+
cd <some-directory>/node_modules/oracledb
117+
<mocha-executable-file-directory>/mocha test/<test-names>
104118
```
105119

106120
See [mochajs.org](http://mochajs.org/) for more information on running tests with mocha.
107121

108122
## Adding Tests
109-
See [CONTRIBUTING](https://github.com/oracle/node-oracledb/blob/master/CONTRIBUTING.md) for general information on contribution requirements.
123+
See [CONTRIBUTING](https://github.com/oracle/node-oracledb/blob/master/CONTRIBUTING.md)
124+
for general information on contribution requirements.
110125

111126
For easy correlation between results and test code, each test is
112127
assigned a number. The following number ranges have been chosen:

0 commit comments

Comments
 (0)