power-assert-js / espower-typescript

power-assert instrumentor for TypeScript
https://npm.im/espower-typescript
86 stars 11 forks source link

how to use with jest #53

Open qingfengpai opened 6 years ago

teppeis commented 6 years ago

Sorry, I don't use Jest with this package. Someone could help?

twada commented 6 years ago

Me neither. So labeled as help wanted.

karak commented 6 years ago

@qingfengpai I'm not a user of power-assert but ts-jest may help you. Sample: https://github.com/karak/power-assert-ts-jest

twada commented 6 years ago

@karak Thanks a lot!!

YusukeHirao commented 6 years ago

@karak I expect to report

 - Expected
    + Received

    - Object {
    -   "greeting": "Hello",
    - }
    + Object {}

      assert.equal({}, { greeting: "Hello" })
                   |   |
                   |   Object{greeting:"Hello"}
                   Object{}

but actual result

    - Expected
    + Received

    - Object {
    -   "greeting": "Hello",
    - }
    + Object {}

      2 |
      3 | it("hello", () => {
    > 4 |   assert.equal({}, { greeting: "Hello" });
        |          ^
      5 | });
      6 |

Have you hit on any possible causes of the problem?

karak commented 6 years ago

I confirmed the version of pure-js gave the same result, and can only say "power-assert" and/or "jest" may have some problems rather than TypeScript.

ADD:

The following command-lines are against your expects as well.

npx jasmine hello.test.js
npx mocha hello.test.js

Is the usage of power-assert correct? I'm not sure.

YusukeHirao commented 6 years ago

@karak Thank you, sorry for asking too much. Let me check it out.

taichi commented 6 years ago

i made quick example here. https://gist.github.com/taichi/d000fa1eba03889be58bdf985c922f87