Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-35595

Javascript unit testing

XMLWordPrintable

    • MDL-35595-master-mocha
    • Hide
      1. With the plugin installed go to the Admin tree -> Development -> JSUnit
      2. The block_community test SHOULD be executed
      3. Create a new YUI test module
        1. You can copy & paste blocks/community/yui/commentstest/commentstest.js as another yui module (More info in http://docs.moodle.org/dev/JSUnit#Creating_tests)
        2. Execute the test again, the results SHOULD be correct and the different tests indentations SHOULD respect the following ul/li tags structure:
      • Name: I'm the test case name (name setting of Y.Test.TestCase)
      • Passed tests: N
      • Failed tests: N
        • Name: test_name
        • Result: pass|fail
        • Message: Test passed|*
      • Name: I'm another test case name
      • Passed tests: N
      • Failed tests: N
        • Name: test_another_name
        • Result: pass|fail
        • Message: Test passed|*
        • Name: test_another_one
        • Result: pass|fail
        • Message: Test passed|*
      Show
      With the plugin installed go to the Admin tree -> Development -> JSUnit The block_community test SHOULD be executed Create a new YUI test module You can copy & paste blocks/community/yui/commentstest/commentstest.js as another yui module (More info in http://docs.moodle.org/dev/JSUnit#Creating_tests ) Execute the test again, the results SHOULD be correct and the different tests indentations SHOULD respect the following ul/li tags structure: Name: I'm the test case name (name setting of Y.Test.TestCase) Passed tests: N Failed tests: N Name: test_name Result: pass|fail Message: Test passed|* Name: I'm another test case name Passed tests: N Failed tests: N Name: test_another_name Result: pass|fail Message: Test passed|* Name: test_another_one Result: pass|fail Message: Test passed|*

      YUI includes a unit testing framework (http://yuilibrary.com/projects/yuitest/) but is not used by Moodle, it could be good to have an execution wrapper to allow Moodle components to write unit tests for it's YUI 3 modules; the YUI test version included in the YUI 3 library allows testing of all kind of JS, not only YUI modules (they can be tested inside a YUI 3 module) It outputs the tests results in different formats including JUnitXML

      Working on it during the STABLE team week off.

      If it needs to be executed from CLI there is an available tool YUI yeti (http://yuilibrary.com/projects/yeti/) with Node.js dependencies that can test JS code against multiple browsers.

            Votes:
            15 Vote for this issue
            Watchers:
            29 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 days
                4d

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.