Skip to content
This repository has been archived by the owner on Jul 26, 2023. It is now read-only.

JsTestDriver integration #95

Closed
subtubes-io opened this issue Oct 7, 2012 · 5 comments
Closed

JsTestDriver integration #95

subtubes-io opened this issue Oct 7, 2012 · 5 comments

Comments

@subtubes-io
Copy link

Not sure what I am doing wrong but doesnt seem to work with JSTestDriver
for loading fixtures in JsTestDriver a jasmine config is not necessary can you explain how we could load fixtures with JsTestDriver?
Thanks much appreciated

@travisjeffery
Copy link
Collaborator

I have no idea I don't use jstestdriver, post a whole piece of code to look at and make sure you're not doing something wrong at least.

@justlaputa
Copy link
Contributor

I have used jsTD with jasmine, jasmine-jquery to test website, and it works OK. I use jstd-maven-plugin to run jstd, but I also tried to use java command line, they are both ok. Here is my src/test/ directory tree:

test
├── js
│   ├── fixtures
│   │   ├── css
│   │   │   └── bootstrap.min.css
│   │   └── index.html
│   └── testSpec.js
└── resources
    ├── jasmine
    │   ├── jasmine.css
    │   ├── jasmine-html.js
    │   ├── jasmine-jquery.js
    │   ├── jasmine.js
    │   └── MIT.LICENSE
    ├── jstd
    │   ├── coverage-1.3.4.b.jar
    │   ├── JasmineAdapter.js
    │   └── JsTestDriver-1.3.4.b.jar
    └── jsTestDriver.conf

jsTestDriver.conf:

server: http://localhost:4224

load:
 - src/test/resources/jasmine/jasmine.js
 - src/test/resources/jstd/jasmineAdapter.js
 - src/main/webapp/js/lib/require-jquery.js
 - src/test/resources/jasmine/jasmine-jquery.js
 - src/main/webapp/js/lib/*.js

test:
 - src/test/js/*.js

serve:
 - src/test/js/fixtures/*.html
 - src/test/js/fixtures/css/*.css

plugin:
 - name: "coverage"
   jar: "src/test/resources/jstd/coverage-1.3.4.b.jar"
   module: "com.google.jstestdriver.coverage.CoverageModule"

timeout: 600

and a sample spec file:

describe("sample test", function() {

        beforeEach(function() {
            //need to use absolute path here for jstd-maven-plugin
            jasmine.getFixtures().fixturesPath = '/test/src/test/js/fixtures';
            loadFixtures('index.html');

            //need this css to use `toBeHiden` and `toBeVisible` matchers
            jasmine.getStyleFixtures().fixturesPath = '/test/src/test/js/fixtures/css';
            loadStyleFixtures('bootstrap.min.css');
        });

        describe("when user click something", function() {

            it("should show something", function() {
                expect($('#a-page')).toBeHidden();
                expect($('#b-page')).toBeHidden();

                $('#course1').click();
                expect($('#a-page')).toBeVisible();
                expect($('#b-page')).toBeHidden();
            });
        });
    });
});

@travisjeffery
Copy link
Collaborator

Thanks @justlaputa for posting that, looks pretty thorough. I'll link to this issue from the README in-case other jstd users come along.

@justlaputa
Copy link
Contributor

Thanks, glad to be helpful!

@subtubes-io
Copy link
Author

thank you for posting that. Sorry I had not posted back in a few days I got tied up with work. I'll try this out tonight.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants