Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion hardhat-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const config = {
mocha: {
exit: true,
bail: false,
recursive: false,
timeout: 0,
slow: 5000,
jobs: Number(process.env.MOCHA_JOBS) || 3,
Expand Down
30 changes: 29 additions & 1 deletion hardhat-config/tasks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const fs = require('node:fs');
const path = require('node:path');

const { extendEnvironment, task } = require('hardhat/config');
const { TASK_TYPECHAIN } = require('@typechain/hardhat/dist/constants');
const { TASK_COMPILE } = require('hardhat/builtin-tasks/task-names');
const { TASK_COMPILE, TASK_TEST } = require('hardhat/builtin-tasks/task-names');

extendEnvironment(hre => {
hre.nexus = require('../lib');
Expand Down Expand Up @@ -40,3 +43,28 @@ task('coverage').setAction(async function (args, hre, runSuper) {
};
return runSuper();
});

task(TASK_TEST).setAction(async function (args, hre, runSuper) {
args.testFiles = args.testFiles.flatMap(file => {
// pass as is if it's a file
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
return [file];
}

// then try as a glob
const items = fs.globSync(file);

if (items.length === 0) {
// if nothing matched - return the original path so it can gracefully fail down the pipeline
return [file];
}

return items.flatMap(item => {
return fs.statSync(item).isDirectory()
? fs.globSync(path.join(item, '**/*.js')) // scan for tests
: [item]; // return as is
});
});

return runSuper();
});
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,15 @@
"lint": "npm run lint:js && npm run lint:solidity",
"lint:js": "eslint --max-warnings 0 .",
"lint:solidity": "slippy 'contracts/**/*.sol'",
"dev": "nodemon --ext js,sol -x hardhat test 'test/unit/**/*.js' 'test/integration/**/*.js' 'test/layout/*.js' --show-stack-traces",
"dev-integration": "nodemon --ext js,sol -x hardhat test 'test/integration/**/*.js' --show-stack-traces",
"dev-unit": "nodemon --ext js,sol -x hardhat test 'test/unit/**/*.js' --show-stack-traces",
"dev-ui": "hardhat run scripts/local-deploy.js",
"dev": "nodemon --ext js,sol -x hardhat test test/unit test/integration test/layout --show-stack-traces",
"dev-integration": "nodemon --ext js,sol -x hardhat test test/integration --show-stack-traces",
"dev-unit": "nodemon --ext js,sol -x hardhat test test/unit --show-stack-traces",
"coverage": "NODE_OPTIONS='--max-old-space-size=8192' hardhat coverage --testfiles 'test/{unit,integration}/**/*.js'",
"test": "hardhat test 'test/unit/**/*.js' 'test/integration/**/*.js' 'test/layout/*.js'",
"test-integration": "hardhat test 'test/integration/**/*.js'",
"test-unit": "hardhat test 'test/unit/**/*.js'",
"test-layout": "hardhat test 'test/layout/*.js'",
"test": "hardhat test test/unit test/integration test/layout",
"test-integration": "hardhat test test/integration",
"test-unit": "hardhat test test/unit",
"test-layout": "hardhat test test/layout",
"test-fork": "TEST_ENV_FORK=http://localhost:8545 hardhat test test/fork/index.js",
"deploy": "hardhat run scripts/deploy/deploy.js",
"deploy-local": "hardhat run scripts/deploy/start.js",
"typechain": "hardhat typechain",
"deployments:build": "node deployments/build.js",
"deployments:publish:next": "cd deployments && npm publish --access public --tag next",
Expand Down
Loading
Loading