approvals / Approvals.NodeJS

Approval Tests implementation in NodeJS
Apache License 2.0
104 stars 41 forks source link

Using ApprovalTests in a typescript test file ! #78

Open mike03081972 opened 6 years ago

mike03081972 commented 6 years ago

Is it possible to publish also the declaration file for module 'approvals' (.d.ts)

=> npm install @types/approvals` => yarn add @types/approvals

staxmanade commented 6 years ago

Happy to help maintain a .d.ts - mind sending a PR with how this is configured within a typical repo?

mike03081972 commented 6 years ago

Hi,

I'm pretty new in Javascript/typescript. I don't know how to write this file but whenI have some times, I will try to investigate it.

Some infos when I try to use it :

I will receive this message from WebStorm

The code looks like this :

import {mocha} from 'approvals';

mocha();

describe('When running some tests', function () {

it('should be able to use Approvals', function () {

    let value = 'HELLO WORLD';

    this.verify(value);
});

});

Thanks,

2018-04-29 21:53 GMT+02:00 Jason Jarrett notifications@github.com:

Happy to help maintain a .d.ts - mind sending a PR with how this is configured within a typical repo?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/approvals/Approvals.NodeJS/issues/78#issuecomment-385276830, or mute the thread https://github.com/notifications/unsubscribe-auth/AWLkMVj_vwn34yDbtAufwSrS5w8Fw2tuks5tthpLgaJpZM4TjmDM .

mike03081972 commented 6 years ago

approval-ts-test.zip

Hi,

You will find attached an example project that works under typescript. The .d.ts files is located in the folder typings

Best regards

labsvisual commented 5 years ago

@staxmanade wouldn't mind contributing to the repository with typings and their documentation. 😄

staxmanade commented 5 years ago

@labsvisual Please do - would love some pull requests and help...

labsvisual commented 5 years ago

@staxmanade on it!

DanKaplanSES commented 2 years ago

Would it be an option to change the project to a typescript project? I'd be interested in submitting a PR for that. It would still work for JS users.

staxmanade commented 2 years ago

@DanKaplanSES I would be open to this. @isidore and I have had a few weekend pairing sessions over the summer - perhaps something we could all jump into in the coming months and work on together.

DanKaplanSES commented 2 years ago

I'm down. Let me know.

claremacrae commented 2 years ago

Hi Jason!

I'm helping someone in the Obsidian plugin community to start writing approval tests for some typescript-based code...

I've pointed them at this issue, to see if the attachments help... Will report here how we get on...

SkepticMystic commented 2 years ago

Thanks Clare :) @mike03081972 I managed to get your example project working. However, the issue I had before is that I cannot import functions from other files in the project into the test.specs.ts file. If I want to test myFunc from utils.ts, for example, I add import {myFunc} from '../src/utils', but I get the following error: image

It feels like there should be a way around this. Surely I should be able to import functions into the test file.

EDIT: I can import local functions from other files. The issue seems to arise from using 3rd-party libs in those other files

claremacrae commented 2 years ago

EDIT: I can import local functions from other files. The issue seems to arise from using 3rd-party libs in those other files

I wonder whether it's worth starting from the other end, from the starter project - which does already import a source file from another location... And seeing if you can add to that the use of a 3rd-party lib.

https://github.com/approvals/ApprovalTests.js.StarterProject