mithril.js icon indicating copy to clipboard operation
mithril.js copied to clipboard

Testing Tutorial

Open JhonSmithRomeroSolorzano opened this issue 3 years ago • 4 comments

Hi every body.

I'm doing the testing tutorial, wich is in https://mithril.js.org/testing.html

I did each step exactly as suggested, with the suggested file structure, but I'm geeting this result.

Result

There is no error but the component was not tested either.

Code

component-test component setup pakage

I want to know what I am skipping, or what step does not have the tutorial that I am skipping. I really appreciate the help you can give me since I have to start testing my application.

@JhonSmithRomeroSolorzano I can confirm it doesn't work out of the box. I don't have the time today to figure out why not, but maybe someone else can. I think that out.should.contain("day") doesn't work anymore (it should be something like o(testvalue).equals('expected value') now), but that's not the reason it doesn't work.

osban avatar Apr 03 '21 10:04 osban

I'm facing same.

mchampaneri avatar Apr 10 '21 14:04 mchampaneri

I'm seeing the same stuff, and I can't figure out why. Worth enumerating the other problems with the test documentation:

  1. It doesn't install Mithril
  2. It doesn't bind the Mithril module to global in test-setup.js
  3. It's confused about whether it's using ospec or mocha - step 1 says to add "test": "mocha" to your scripts but then immediately tells you to use ospec instead; later the test file uses ospec test specifications but mocha assertions.

I've tried variations of the command line and nothing seems to work for this setup. Strange!

barneycarroll avatar Apr 14 '21 20:04 barneycarroll

I also struggled with the Mithril documentation for testing. Then I did set up a testing environment for a JS application, using Webpack and Mocha. So I took some time to write a tutorial and a sample application: https://gitlab.com/Mytskine/mithril-real-world. Mocha tests are run locally and with Gitlab-CI. Hope that helps.

mytskine avatar Apr 21 '21 10:04 mytskine