noisy-jasmine
v1.0.2
Published
Tools to make Jasmine testing in Node a little easier
Downloads
4
Readme
noisy-jasmine
Implements jasmine pre-configurations and test runner tools.
run-tests.js
Executing ./run-tests.js
will:
- trigger es-linting of the project an print out the results
- execute all tests, regardless if errors where detectd during linting.
While I very much appreciate tools like eslint, I usually want to see if my code
execute correctly first and have the choice to defer fixing linting issues.
Using ./run-tests.js
, we get a report on issues, but unlike
"pretest": "eslint ."
, the tests will still execute.
tdd
./run-tests.js
supports a continuous run mode. In this mode, the test runner
executes, then watches for file changes in the projects spec, lib and
server folders.
To run the tests in continuous run or tdd mode, run
node_modules/noisy-node-dev-tools/run-tests.js continuously
.
Less linting, more testing
You can skip linting in ./run-tests.js
by setting the without-linting
flag.
With that flag set, the script will only execute the test runner.
Note: Currently only the first command line argument is observed, so you cannot run
without_linting
and continuously
at the same time.
package.json
{
"scripts": {
"test": "node node_modules/noisy-node-dev-tools/run-tests.js",
"test-no-lint": "node node_modules/noisy-node-dev-tools/run-tests.js without-linting",
"tdd": "node --inspect node_modules/noisy-node-dev-tools/run-tests.js continuously"
}
With the above configuration, you can execute single test runs via npm test
and tdd continuous runs via npm run tdd
.
The --inspect
flag is optional of course. it simply allows you to connect a
debugger while running your tests.
test-util/generate-uit-path.js
test-util/generate-uit-path.js
can be used in spec files to resolve
paths to uit source-files, if those spec files:
- end in
-spec.js
.(Spec.js|spec.js
) are currently not supported - are located in a directory that follows the same structure as the repo root.
Example:
project-root
├── spec
│ └── test-util
│ └── generate-uit-path-spec.js
└── test-util
└── generate-uit-path-spec.js
The spec
folder, which contains all Jasmine test files, has the same folder
structure as project-root.
I.e. the spec file is located
at test-util/generate-ui-path-spec.js
with its root ar project-root/spec
,
while the uit file is located at 'test-util/generate-ui-path.js', but directly
under project-root
.
// file: ./spec/lib/generate-uit-path-spec
describe( 'The generateToUITPath function', ()=>{
it( 'should resolve the path from its own test file to its own script',()=>{
const pathToUnitInTest
= '../../lib/generate-uit-path';
const generateUITPath
= require( pathToUnitInTest );
expect( generateUITPath( __filename ) )
.toEqual( pathToUnitInTest );
} );
} );