Does mocha have a testing live mode? - mocha.js

I am doing TDD with mocha and chai to test some NodeJS scripts, and I have to run "mocha" every time that I want to run the test again.
Is there a way to setup mocha and chai to run the test just after I save the source file? like an option "mocha -–live-reload" (that is just an example...)

According to the docs, the --watch flag should do this.

Related

How to use jest in clojurescript?

After I installing jest using npm install jest and adding "test":"jest" in package.json, I expect keywords like "expect" to work automatically in my cljs test files:
(.toBeInTheDocument (expect (.getByText screen "Some Component")))
But I get that "expect" is undefined. js/expect gives undefined as well. How to get jest to work with clojurescript?
-- EDIT --
I installed lint a this library, but still can't get jest functions to work in my test file.
This is not what you asked, but I think most ClojureScript projects use tests written with clojure.test and mocking facilities of the language (eg. with-redefs), so I think it will be much easier to follow that path instead.
Check these links depending on the build tool that you use for your project:
figwheel: https://figwheel.org/docs/testing.html
shadow-cljs: https://shadow-cljs.github.io/docs/UsersGuide.html#_testing

Not able to launch Cypress Runner

When I enter command C:\Users\gurpr\Documents\Cypress_demo>node_modules\.bin\cypress open, I am getting the error
Error: Cannot find module 'C:\Users\gurpr\Documents\Cypress_demo\node_modules\cypress\bin\cypress'
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)[39m
[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)[39m
[90m at internal/main/run_main_module.js:17:11[39m {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: []
}
Install Cypress Globally(not recommended)
In order for cypress open to work as you expect, you need to install cypress globally npm install cypress -g. I'm not positive why Cypress discourages this, but it probably relates to versioning. If you globally install and use cypress open you could be using a different version than the one specified in the package.json. Your team will get frustrated if you have different results when you run the test with your globally installed cypress instance while they run cypress with the package.json version. Command line will also behave differently. I wouldn't do this.
Use npx to Open/run Cypress
I use npx cypress open or npx cypress run in my package.json script definitions.
Uninstall Cypress Globally
You want to avoid saying "works on my machine..." to your team. I would uninstall cypress globally if you haven't. npm uninstall cypress -g
You can install cypress using npm install cypress -g and open using: cypress open
I would recommend to use this way if you are installing cypress only for practice point of view. It would solve your problem.

On Travis how do I modify tests to use minitest instead of rspec?

The link for ask question on Travis dot com sent me here. My tests fail because I'm using minitest in my gem but travis uses rspec. Is there a way to get travis to do that also? Of course I can always modify my tests to use rspec but I'm not sure how to get tests or spec from my structure of my tests. They all have assert_equal which is not recognized by respec as a valid method. Is there a common way to make either test work with the same *_spec.rb files?
This is another option to run your test in your .travis.yml:
script:
- bin/rails test
Remeber to install the gems before run the scripts.
I found in the docs that it is possible to define custom commands for running tests (rather than the default bundle exec rake test) by placing these lines in .travis.yml
script:
- bundle exec rake build
- bundle exec rake builddoc

Ruby Gem Testing Workflow

What is the standard for testing while creating ruby gem?
Do most people run something like guard, or write tests and trigger them manually from the command line?
In Ruby there isn't really a "standard", instead people usually use what works well for them. If you don't like things like guard and prefer to run the tests from the command line, run the tests from the command line.
When I'm coding I run my tests manually from the command-line, but I also have a cron job that will run the tests against the latest commits and email the results every night.

cucumber debugger not stopping

I'm trying to debug a simple BDD test using cucumber. In order to do that, I inserted a debugger statement where I would like to break the control flow. But it seems that cucumber ignores this statement.
I'm running the tests executing:
rake cucumber:wip
It's rather simple, so I think the code isn' t worth pasting here. Thanks in advance
You don't have the rails-debug gem installed and/or included.
Make sure rails-debug listed in your Gemfile
If it's still not being included, make sure you run cucumber like:
bundle exec cucumber ...

Resources