Differing Results with `truffle test` and `truffle test ./test/...`
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
When calling truffle test, I am getting different results to truffle test ./test/... on a specific file.
The test in question is here, and I am doing the setup in a separate file:
The failure I am receiving on the truffle test run mentions
shouldFailWithMessage (node_modules/openzeppelin-test-helpers/src/shouldFail.js:14:10)
in the before all hook. Which is not being called in this file. I have a feeling that there may be some kind of leak from a previous test that is causing this.
Steps to Reproduce
git clone https://github.com/partial-f/core.git
git checkout develop
npm install
truffle test
truffle test ./test/ProductTeller.test.js
Expected Behavior
Expected the same results for the contract, regardless if called in isolation or with all of the tests.
Actual Results
truffle test
6) Contract: ProductTeller
"before all" hook: prepare suite:
Uncaught AssertionError: Expected failure not received
at shouldFailWithMessage (node_modules/openzeppelin-test-helpers/src/shouldFail.js:14:10)
at process._tickCallback (internal/process/next_tick.js:68:7)
7) Contract: ProductTeller
"before each" hook: before test for "should allow an admin to set a product fee":
TypeError: Cannot read property 'call' of undefined
8) Contract: ProductTeller
"after each" hook: after test for "should allow an admin to set a product fee":
TypeError: Cannot read property 'call' of undefined
truffle test ./test/ProductTeller.test.js
Contract: ProductTeller
...
12 passing (25s)
1 pending
1 failing
...
Environment
- Operating System: 10.14
- Truffle version (truffle version): v5.0.5
- node version (node --version): v10.14.2
- npm version (npm --version): 6.4.1
- ganache-cli: Ganache CLI v6.3.0 (ganache-core: 2.4.0)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:21 (6 by maintainers)
Top Results From Across the Web
Test your contracts - Truffle Suite
Truffle comes standard with an automated testing framework to make ... This framework lets you write simple and manageable tests in two different...
Read more >Writing test in solidity - DApp develop framework | PlatON
Solidity test contracts live alongside Javascript tests as .sol files. When platon-truffle test is run, they will be included as a separate test...
Read more >truffle - should I remember the results of previous calls?
Truffle tests are based on mocha framework so you can use similar approach. Create multiple contract sections for the same contract.
Read more >truffle test guide - Rafaela Azevedo
Posts about truffle test guide written by Rafaela Azevedo.
Read more >Testing smart contracts using Truffle - RSK Developers Portal
The truffle test command performs tests on all files found in the test directory. Now we have 2 files with tests. To run...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@CruzMolina All the tests are finally passing! 🎉 I removed the
chai.assertdeclaration, and removedbn-chaiand refactored my tests to useshould.equalrather thanshould.eq.BN. Thanks again for your help!Ah, okay. Looks like you are in the process of updating from truffle 4 to truffle 5.
I’ve invited you to a private repo w/ a branch I worked on real quick to help you along (would have just pushed my local branch but I don’t think I have proper permissions from your repo). It turns out (at least in v5), we already expose
chai.assertinternally for running js tests, so declaringconst assert = chai.assertwas causing what appears to be an overloading error. Can simply start usingassert()w/o needing to require the lib.The other issue I noticed is you’re using
bn-chai, which (for whatever reason) wasn’t written to supportshould(). There appears to also be an overloading error happening there as well betweenchaiandbn-chai.For replacing the test comparisons, I pushed an example suggestion to get you guys started.
Currently only 34 tests fail on my end, yay! 🎉