Skip to content

Commit 3df75f1

Browse files
committed
feat(@embark/test-runner): introduce artifacts.require API
This commit adds a convenience API `artifacts.require(name)` that aims to make requiring artifacts a little bit more straight forward. Usage: ``` const SimpleStorage = artifacts.require('SimpleStorage'); const EmbarkJS = artifacts.require('EmbarkJS'); ```
1 parent 84448f8 commit 3df75f1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

dapps/tests/app/test/simple_storage_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*global contract, config, it, assert, web3*/
2-
const SimpleStorage = require('Embark/contracts/SimpleStorage');
2+
const SimpleStorage = artifacts.require('SimpleStorage');
33
let accounts;
4-
const {Utils} = require('Embark/EmbarkJS');
4+
const {Utils} = artifacts.require('EmbarkJS');
55

66
config({
77
contracts: {

packages/plugins/mocha-tests/src/lib/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,15 @@ class MochaTestRunner {
222222
global.config = config;
223223
});
224224

225+
global.artifacts = {
226+
require: (name) => {
227+
if (name === 'EmbarkJS') {
228+
return EmbarkJS;
229+
}
230+
return require(`Embark/contracts/${name}`);
231+
}
232+
}
233+
225234
mocha.suite.timeout(TEST_TIMEOUT);
226235
mocha.addFile(file);
227236

0 commit comments

Comments
 (0)