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

Support custom context file #1277

wants to merge 1 commit into


None yet
2 participants

krasimir commented Jan 2, 2015


Karma is a wonderful spec runner. However, it is kinda design to work with AngularJS. I'm at the moment exploring various ways of testing client side code. Some frameworks (or apps) require having <script> or HTML tags on the page in order to work. I'm using TODOMVC as a example and I'm trying to test it by using different tools. This PR introduces one more property to the client configuration item.

module.exports = function(config) {

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: '',

    client: {
      contextFile: '/TestRunner.html'


The content of the TestRunner.html is the same as the content of static/context.html. The only one difference is that I added what I needed there. In my case this was a Backbone app and I placed the templates along with the application's HTML. Here is how my test suite looks like:

describe("Testing TODOMVC", function () {

    var setText = function(text, selector) {
        var input = $(selector || '#new-todo');
        var e = $.Event("keypress");
        e.which = e.keyCode = 13;
        return input.val(text).trigger(e);

    before(function() {
        window.localStorage.removeItem('todos-backbone', '');

    it("Adding new TODOs", function () {
        setText('TODO A');
        setText('TODO B');
        expect($('#todo-list li').length);

    it("Deleting TODO", function () {
        $('#todo-list li:first-child .destroy').click();
        expect($('#todo-list li').length);

    it("Edit and add TODOs", function () {
        setText('A new TODO');
        $('#todo-list li:first-child').addClass('editing');
        setText('A new TODO', '#todo-list li:first-child .edit').blur();
        expect($('#todo-list li').length);
        expect($('#todo-list li label').eq(0).text())$('#todo-list li label').eq(1).text())


Ref: #488


This comment has been minimized.

Show comment
Hide comment

dignifiedquire Jan 4, 2016


Closing due to inactivity


dignifiedquire commented Jan 4, 2016

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment