I set up a unit test on a SimpleStorage that works with OZ Hub and relay running on a ganache instance I get 0 passing. I tried the test on a nonOZ working version of my Solidity code and I get errors :
Hey @Steeve! If you’re running your tests via truffle test, you may need to somehow have Babel parse your js code (if you’re using an old node.js). This is typically done by adding the following to your truffle config file:
Did that ,and made sure the babel dependencies are in the package.json also
however I get a polyfill error (may be related to Vue framework conflicts):
TypeError: Cannot destructure property `polyfills` of 'undefined' or 'null'. (While processing preset: "/home/workspace/SimpleStorage/node_modules/@vue/babel-preset-app/index.js")
at module.exports (/home/workspace/SimpleStorage/node_modules/@vue/babel-preset-app/polyfillsPlugin.js:19:5)
Yes , after attempting to go with OZ testing I solved by sticking with Truffle test “contract” framework and plain mocha/chai for function logic unit testing.
//const { BN, constants, expectEvent, shouldFail } = require('openzeppelin-test-helpers');
var assert = require('chai').assert
require("babel-register");
const SimpleStorage = artifacts.require("SimpleStorage");
contract("contract test", accounts => {
beforeEach(async function () {
});
it("sets value equal to expected value", async () => {
let val = 88
let instance = await SimpleStorage.deployed()
await instance.set(val)
await instance.get().then((r) => {
assert.equal(val,r.toNumber());
})
})
});
})
describe("Tests", function () {
it('does something', () => {
const msg = 'new message'
assert.equal(msg, 'new message','ok')
})});