Truffle Solidity - ERR "before each" hook: before test for "it is not possible to send more token than available" - mocha.js

im writing some tests for ERC20 using OpenZeppelin contract.
For tests i was using Chai and Mocha.
this is my source code:
enter image description here
and this is an error:
enter image description here
I didn't make any assertion in 3rd test, and i have no idea why it's compering them(

Related

Why Cypress gives success after second attempt?

In my Cypress tests, I create some data in before block and then my test script is run that locates in it block. I checked business side flow and it seems like there is no error about app side. I just want to understand that why my test's result is success after second attempt. Does Cypress has this kind of solution to handle an error maybe?
Cypress has the ability to automatically retry any failed tests. I would check your Cypress configuration's value for retries.openMode.

How can I post my test reports to an API?

I've created a test using the samples. It works great. Test works really nice.
But I couldn't find about how can I send reports to an API after each test.
I want to post the reports like "Test Successfull and these are passed" or "Test Failed and these are failed things" + maybe upload also the screenshot it generates".
How can I do this?

Nightwatch does not create html report , If there is any run-time failure in nightwatch

I am using this module -https://bl.ocks.org/denji/204690bf21ef65ac7778 to create html report for my nightwatch test. Test report creates successfully if there is no run-time error during the test run. for an example it creates html report successfully even if one of the assertion fail, as long as there is no run-time error.
however if there is any error thrown like below then , it does not create html report including all the test suites it ran.(please check the screen-shot i've attached as well). How can i capture all the failures in the html-report and create the report successfully.
POST /wd/hub/session/fd34aff5c708035939c98efd74afd866/elements - ECONNRESET
Error: socket hang up
at connResetException (internal/errors.js:570:14)
at Socket.socketCloseListener (_http_client.js:380:25)
Error while running .locateMultipleElements() protocol action: An unknown error has occurred.```
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/ZgOat.png
The problem is not about html-report. Its about junit xml report. The junit xml report is not generated when the element is not found. https://github.com/nightwatchjs/nightwatch/issues/1977.
I was using the version nightwatch 1.3.2. Better solution is to update to the latest version 1.3.4

Verify the response code of the page with Capybara and Selenium

I'm trying to verify the response code of a page by using capybara. I used the expect statement as -
expect(page.status_code).to eq(404)
I'm getting the error as -
Capybara::NotSupportedByDriverError:
Capybara::Driver::Base#status_code
Might be status_code is not supported by Capybara. Is there any other way to verify the status/response code or I'm doing something wrong in the expect statement.
The Selenium driver doesn’t support status_code because it’s not really something you should be testing in a feature/system test. The idea of feature/system tests (which Capybara is aimed at) is to test from a users perspective. Since a user cares about what is shown in the browser thatts what should be tested for rather than the status code. If you still want to test for the status code it should be done in a request spec rather than a feature/system spec
If you don't need JavaScript you can try to fall back on the default rack_test driver:
it "responds with status code 404", js: false do
expect(page.status_code).to eq(404)
end

capybara-webkit: automatically save a screenshot on an RSpec test failure

How can I automatically save the html and a screenshot when a test fails using capybara-webkit with Rspec? How can I execute a callback when an RSpec test fails.
Bonus points: how can I avoid getting the following error:
Capybara::Driver::Webkit::WebkitInvalidResponseError
when executing this code:
require 'capybara/util/save_and_open_page'
path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}"
png = Capybara.save_and_open_page_path + "#{path}.png"
page.driver.render Rails.root.join(png)
I have written a gem Capybara-Screenshot specifically for this, check out https://github.com/mattheworiordan/capybara-screenshot
It will automatically create screen shots on failed RSpec or Cucumber steps.
Capybara provides a function for saving and opening a screenshoot during the testing. You just need to call anywhere in your test:
save_and_open_screenshot
and it will open a picture how the test looks like at that point.
No need for any additional gems.
Capybara::save_and_open_screenshot
Found a gist that might help you https://gist.github.com/1156691

Resources