espower-typescript icon indicating copy to clipboard operation
espower-typescript copied to clipboard

how to use with jest

Open qingfengpai opened this issue 7 years ago • 8 comments

qingfengpai avatar Jul 08 '18 11:07 qingfengpai

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

teppeis avatar Jul 08 '18 14:07 teppeis

Me neither. So labeled as help wanted.

twada avatar Jul 09 '18 01:07 twada

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

karak avatar Jul 09 '18 04:07 karak

@karak Thanks a lot!!

twada avatar Jul 09 '18 07:07 twada

@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?

YusukeHirao avatar Jul 12 '18 04:07 YusukeHirao

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.

karak avatar Jul 12 '18 11:07 karak

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

YusukeHirao avatar Jul 13 '18 01:07 YusukeHirao

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

taichi avatar Oct 31 '18 09:10 taichi