Quantcast
Channel: Chutzpah - A JavaScript Test Runner
Viewing all articles
Browse latest Browse all 1864

Commented Issue: jasmin-jQuery toContain tests fail with reason "Passed." [95]

$
0
0
I've got some tests that use jasmin-jQuery's `toContain(jQuerySelector)` matcher to check for the existence of an input tag in some html that was loaded by jasmine-jQuery's `loadFixtures(fixtureUrl[, fixtureUrl, ...])`

All my tests pass in Chrome, but tests that use the toContain matcher fail in Chutzpah 2.3.0 with the following message:

```
Test 'Keyboard:should have 13 buttons when the accept button option is set' failed
Passed.
in C:\bschoenfeld\OPs_Service_Bus\VIT.NIT.OPS.HatchChecker\WebServer\Apps\HatchChecker\test\SpecRunner.html (line 0)
```

Here is the failing test:
```
it("should have 13 buttons when the accept button option is set", function() {
var keyboard = new Keyboard.View({ placeholder: '', acceptButton: true });
keyboard.render();
expect(keyboard.$el).toContain('input');
expect(keyboard.$('.btn').length).toBe(13);
});
```

The work around is to explicitly call the jQuery selector in the test and check the length. This test passes in Chutzpah:
```
it("should have 13 buttons when the accept button option is set", function() {
var keyboard = new Keyboard.View({ placeholder: '', acceptButton: true });
keyboard.render();
expect(keyboard.$('input').length).toBe(1);
expect(keyboard.$('.btn').length).toBe(13);
});
```

The toContain matcher works in Chutzpah if it's inverted with the `.not` prefix. This test also passes in Chutzpah:
```
it("should have 12 buttons", function() {
var keyboard = new Keyboard.View;
keyboard.render();
expect(keyboard.$el).not.toContain('input');
expect(keyboard.$('.btn').length).toBe(12);
});
```
Comments: Fixed in changeset e28776f49437a869d7fbf77e35675e0c5125f849

Viewing all articles
Browse latest Browse all 1864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>