Integration Tests
We place integration tests in JS in a separate directory at the same level as /src
, called /integration-tests
(read more), placing this folder within a /tests
folder at root-level that contains the unit tests folder would also be plausible. Refer to this folder structure below:
โโโ package.json โต contains `dependencies` for contract and `devDependencies` for workspaces-js tests
โโโ src
โ โโโ index.js โต contract code
โโโ node_modules
โโโ integration-tests โต integration test directory
โโโ tests.js โต integration test file
A sample configuration for this project's package.json
is shown below:
{
"name": "simple-example",
"version": "0.1.0",
"description": "Simple json file example",
"main": "index.js",
"type": "module",
"license": "MIT",
"directories": {
"test": "test"
},
"scripts": {
"build": "near-sdk-js build",
"test": "ava"
},
"dependencies": {
"near-sdk-js": "0.6.0"
},
"devDependencies": {
"ava": "^4.3.3",
"near-workspaces": "^3.2.2"
},
"ava": {
"files": [
"test/**/*.ava.js"
],
"require": [],
"failFast": false,
"timeout": "2m",
"failWithoutAssertions": true,
"environmentVariables": {},
"verbose": true,
"nodeArguments": []
}
}
The tests.js
file above will contain the integration tests. These can be run with the following command from the same level as the test package.json
file:
npm test
Was this page helpful?