chai-karma-snapshot
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -6,4 +6,7 @@ /// <reference types="mocha" /> | ||
interface Assertion { | ||
matchSnapshot(lang?: string, update?: boolean): Assertion; | ||
matchSnapshot(lang?: any, update?: boolean): Assertion; | ||
} | ||
interface AssertStatic { | ||
matchSnapshot(lang?: any, update?: boolean): Assertion; | ||
} | ||
} | ||
@@ -10,0 +13,0 @@ } |
@@ -39,3 +39,11 @@ "use strict"; | ||
utils.addMethod(chai.Assertion.prototype, "matchSnapshot", function (lang, update) { | ||
utils.addMethod(chai.Assertion.prototype, "matchSnapshot", aMethodForExpect); | ||
chai.assert.matchSnapshot = aMethodForAssert; | ||
function aMethodForAssert(lang, update, msg) { | ||
// This basically wraps the 'expect' version of the assertion to allow using 'assert' syntax. | ||
return new chai.Assertion(lang, update, msg).to.matchSnapshot(); | ||
} | ||
function aMethodForExpect(lang, update) { | ||
var obj = serialize(chai.util.flag(this, "object")); | ||
@@ -61,3 +69,3 @@ var path = snapshotPath(context.runnable); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -64,0 +72,0 @@ |
{ | ||
"name": "chai-karma-snapshot", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "lib/index.d.ts", |
@@ -127,3 +127,3 @@ # Chai Plugin for Snapshot Testing with Karma | ||
// __tests__/index.js | ||
import { use, expect } from "chai"; | ||
import { use, expect, assert } from "chai"; | ||
import { matchSnapshot } from "chai-karma-snapshot"; | ||
@@ -135,3 +135,6 @@ import { test } from "../src/index.js"; | ||
it("check snapshot", () => { | ||
// 'expect' syntax: | ||
expect(test()).to.matchSnapshot(); | ||
// 'assert' syntax: | ||
assert.matchSnapshot(test()); | ||
}); | ||
@@ -138,0 +141,0 @@ }); |
8377
75
190