@ -90,11 +90,10 @@ module.exports = {
. waitForElementContainsText ( '*[data-id="testTabTestsExecutionStopped"]' , 'The test execution has been stopped' , 60000 )
. waitForElementContainsText ( '*[data-id="testTabTestsExecutionStopped"]' , 'The test execution has been stopped' , 60000 )
} ,
} ,
'Should fail on compilation' : function ( browser : NightwatchBrowser ) {
'Should fail on compilation, open file on error click, not disappear error ' : function ( browser : NightwatchBrowser ) {
browser . waitForElementPresent ( '*[data-id="verticalIconsKindfilePanel"]' )
browser . waitForElementPresent ( '*[data-id="verticalIconsKindfilePanel"]' )
. addFile ( 'tests/compilationError_test.sol' , sources [ 0 ] [ 'compilationError_test.sol' ] )
. addFile ( 'tests/compilationError_test.sol' , sources [ 0 ] [ 'compilationError_test.sol' ] )
. clickLaunchIcon ( 'filePanel' )
. click ( 'div[title="default_workspace/tests/compilationError_test.sol"] span[class="close"]' )
. openFile ( 'tests/compilationError_test.sol' )
. clickLaunchIcon ( 'solidityUnitTesting' )
. clickLaunchIcon ( 'solidityUnitTesting' )
. pause ( 2000 )
. pause ( 2000 )
. click ( '*[data-id="testTabCheckAllTests"]' )
. click ( '*[data-id="testTabCheckAllTests"]' )
@ -102,6 +101,12 @@ module.exports = {
. scrollAndClick ( '*[data-id="testTabRunTestsTabRunAction"]' )
. scrollAndClick ( '*[data-id="testTabRunTestsTabRunAction"]' )
. waitForElementContainsText ( '*[data-id="testTabSolidityUnitTestsOutput"]' , 'SyntaxError: No visibility specified' , 120000 )
. waitForElementContainsText ( '*[data-id="testTabSolidityUnitTestsOutput"]' , 'SyntaxError: No visibility specified' , 120000 )
. waitForElementContainsText ( '*[data-id="testTabTestsExecutionStoppedError"]' , 'The test execution has been stopped because of error(s) in your test file' , 120000 )
. waitForElementContainsText ( '*[data-id="testTabTestsExecutionStoppedError"]' , 'The test execution has been stopped because of error(s) in your test file' , 120000 )
. click ( '*[data-id="tests/compilationError_test.sol"]' )
. pause ( 1000 )
. getEditorValue ( ( content ) = > browser . assert . ok ( content . indexOf ( 'contract failOnCompilation {' ) !== - 1 ) )
// Verify that compilation error is still present after a file is opened
// usually, tests result is cleared on opening a new file
. verify . elementPresent ( '*[data-id="tests/compilationError_test.sol"]' )
} ,
} ,
'Should fail on deploy' : function ( browser : NightwatchBrowser ) {
'Should fail on deploy' : function ( browser : NightwatchBrowser ) {
@ -207,6 +212,23 @@ module.exports = {
. removeFile ( 'tests/hhLogs_test.sol' , 'workspace_new' )
. removeFile ( 'tests/hhLogs_test.sol' , 'workspace_new' )
} ,
} ,
'Solidity Unit tests with hardhat console log for EVM revert' : function ( browser : NightwatchBrowser ) {
browser
. waitForElementPresent ( '*[data-id="verticalIconsKindfilePanel"]' )
. addFile ( 'tests/ballotFailedLog_test.sol' , sources [ 0 ] [ 'tests/ballotFailedLog_test.sol' ] )
. clickLaunchIcon ( 'solidityUnitTesting' )
. waitForElementVisible ( '*[id="singleTesttests/4_Ballot_test.sol"]' , 60000 )
. click ( '*[id="singleTesttests/4_Ballot_test.sol"]' )
. click ( '#runTestsTabRunAction' )
. pause ( 2000 )
. waitForElementVisible ( '*[data-id="testTabSolidityUnitTestsOutputheader"]' , 120000 )
. waitForElementContainsText ( '#solidityUnittestsOutput' , 'tests/ballotFailedLog_test.sol' , 60000 )
. assert . containsText ( '#journal > div:nth-child(6) > span > div' , 'Check winning proposal:' )
. assert . containsText ( '#journal > div:nth-child(6) > span > div' , 'Inside checkWinningProposal' )
. openFile ( 'tests/ballotFailedLog_test.sol' )
. removeFile ( 'tests/ballotFailedLog_test.sol' , 'workspace_new' )
} ,
'Debug failed test using debugger' : function ( browser : NightwatchBrowser ) {
'Debug failed test using debugger' : function ( browser : NightwatchBrowser ) {
browser
browser
. waitForElementPresent ( '*[data-id="verticalIconsKindfilePanel"]' )
. waitForElementPresent ( '*[data-id="verticalIconsKindfilePanel"]' )
@ -424,7 +446,7 @@ const sources = [
} ,
} ,
'compilationError_test.sol' : {
'compilationError_test.sol' : {
content : `
content : `
pragma solidity ^ 0.7 . 0 ;
pragma solidity ^ 0.8 . 0 ;
contract failOnCompilation {
contract failOnCompilation {
fallback() {
fallback() {
@ -483,6 +505,31 @@ const sources = [
}
}
} `
} `
} ,
} ,
'tests/ballotFailedLog_test.sol' : {
content : ` // SPDX-License-Identifier: GPL-3.0
pragma solidity >= 0.7 . 0 < 0.9.0 ;
import "remix_tests.sol" ; // this import is automatically injected by Remix.
import "../contracts/3_Ballot.sol" ;
import "hardhat/console.sol" ;
contract BallotTest {
bytes32 [ ] proposalNames ;
Ballot ballotToTest ;
function beforeAll ( ) public {
proposalNames . push ( bytes32 ( "candidate1" ) ) ;
ballotToTest = new Ballot ( proposalNames ) ;
}
function checkWinningProposal ( ) public {
console . log ( "Inside checkWinningProposal" ) ;
ballotToTest . vote ( 1 ) ; // This will revert the transaction
}
} `
} ,
'tests/hhLogs_test.sol' : {
'tests/hhLogs_test.sol' : {
content : ` // SPDX-License-Identifier: GPL-3.0
content : ` // SPDX-License-Identifier: GPL-3.0