New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
move UI unit tests away from PHP code and run directly in phantomjs w/ jasmine testing framework #4739
Comments
+1 for MochaJS see #4691 |
@capedfuzz it would be cool if we could reuse some parts of this to write JavaScript unit tests for all the angular code BTW: probably not really useful but just mention it... I built something similar a year ago to run tests using PhantomJS + Jasmine 2.0 but would now use MochaJS. Reckon there is not really anything new for you but just wanted to mention it. There is a testrunner https://github.com/tsteur/titanium-alloy-jasmine-testing/blob/master/tests.js and a loader https://github.com/tsteur/titanium-alloy-jasmine-testing/blob/master/specs/jasmine/utils/loader.js who finds all the test files in a specs directory: https://github.com/piwik/piwik-mobile-2/tree/master/specs |
@tsteur If the tests for the angularjs code will run in a webpage, then you won't need any code I've written. The screenshot tests run directly in phantomjs, not in a webpage. |
@tsteur FYI, I did some thinking and I think the screenshot testing code could be used for angularjs tests too. For example:
I'm not sure how much extra work it will be to get it to work or if there are any big benefits, but I think it's possible. |
awesome work Benaka there! is this ticket closed? |
…nfig option code, placed OmniFixture into a namespace, removed PHP screenshot testcase classes and added fixture for use w/ JavaScript screenshot tests.
… even when --persist-fixture-data is used.
…iwik behavior by storing values in tmp/ file, add hook so plugins can setup their own test environment, reset user password on test fixture setup.
…pository (from UI repository).
…irectories if tests are for plugins, cleaned up path output in console and add .gitignore to DBStats plugin.
…th new screenshot testing code and display location hint in diffviewer output if expected file is stored within plugin and not the UI tests repo.
… runner: --store-in-ui-tests-repo, --use-github-expected.
…creenshot testing config to README and remove unused constant from Config.php.
…ke sure it is run on every test run.
…t page renderer and capture alert()'s during screenshot tests.
…location hint using the processed file path if the expected file does not exist yet.
…t Piwik API/Controller calls.
…lement is a direct child of a .widget element.
…e don't have to wait 30 minutes to see screenshots
Converting UI tests to JavaScript will confer many benefits including:
Steps to complete:
Move all of test environment setup to Fixture class.(done in uiunittests branch)Extend mocha & chai to handle screenshot compare use-case.Create JS script that will run a PHP program to setup the database and run each UI test suite.Modify existing UI tests.Modify travis config to run via phantomjs.Reason for using Jasmine: phantomjs uses Jasmine internally for its tests so we know it'll work. mocha + chai can be used as an alternative.
CC-ing tsteur as per matt's request.
Update: Using mocha + chai is actually easier to get running and easier to extend.
The text was updated successfully, but these errors were encountered: