Skip to content

Latest commit

 

History

History
 
 

tests

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
Tests
-----

To run the test suite:

npm test <subfolder> <seed>

There are two optional arguments:

  <subfolder>
    If you pass a subfolder to filter specs by as the first argument, Jasmine will only look inside for specs inside any subfolders called 'tests'. You can also pass the full path to a JavaScript file which itself contains tests. This is useful for speeding up the test suite initialization.

  <seed>
    If you pass a random number seed as second argument, all of the randomness used in some tests (like random file names, file contents) will be identical each time. This is useful to reproduce the conditions which cause a particular spec to fail.


Writing new tests
-----------------

New unit and integration tests should be stored adjacent to the code to which they apply, inside a folder called 'tests'. 

New long running tests (like the ones which check the code for unused dependencies, and broken links on the website should be stored here) and a corresponding separate action in .github/workflows

To do
-----

- Reproduce the same results from the same <random number seed> used on Blot's continuous integration server (currently courtesy of Github Actions). Right now, for some reason, this does not happen and it makes debugging tests which sometimes fail on Github Actions a little annoying.

- Self-host Blot's continuous integration server. But Github Actions is fine for now.


Pitfalls
--------

- Initially I ran into leaky global state. Then I made use of the test spec context to store things like a test blog or user. This made things much more straightforward.

- I was also confused by error messages showing up under wrong reporter. This was caused by a single spec timing out, and then Jasmine began executing the next. Any errors generated by the timed out spec (there are usually many, because Jasmine runs cleanup functions which delete the test blog) 

- If you quit tests halfway though, reset the db, because the teardown functions to delete blogs, empty tmp dirs wont have run.


About the tests
---------------

Blot uses a testing framework called Jasmine. I'm not that familiar with testing frameworks but it has worked well.