Hi. I have cloned the repo a <https://github.com/p...
# pact-js
t
Hi. I have cloned the repo a https://github.com/pact-foundation/pact-js/tree/master/examples and am looking at the typescript example. I can run this fine, however I tried to copy the typescript example folder to a different location on my laptop so that I could use this as a template without the code for other examples. I deleted the node_modules folder and ran npm i again, but when I run the tests I get the error ...TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts". Does anyone know why this is? Is it something to do with the fact that parent package.json or tsconfig.json are not it folder I copied across? Thanks.
t
Did you also delete package lock?
Ah! This is a mocha problem. When run in-situ, it will be picking up this config file- https://github.com/pact-foundation/pact-js/blob/master/.mocharc.json<https://github.com/pact-foundation/pact-js/blob/master/.mocharc.json|
Which has the typescript settings in it
You’ll need to copy that file in to your directory
👍 1
t
Thanks. This resolved it (after I changed 'src' to 'test'.
What do you mean 'run in situ'?
it seems to run tests based on the path specified in the mocharc.json file even if the specific path is specified in the package.json scripts.
t
Sorry, by “run in situ” I meant running the example directly without the rest of pact-js around it. It wasn’t a good way to explain what I meant. Yes, mocha has some unintuitive preference rules
*precedence
I think Jest is more popular these days. Pact doesn’t care which test runner you use
t
Ok, thanks Timothy. Think Im just using mocha as that came with example I am learning from and don'r know how to add jest and remove mocha without breaking the whole thing.
t
It shouldn’t matter which one you use
If you already know Jest, I can put together an example for you over the weekend, but if you don’t know either I would just stick with Mocha
t
Thanks for the offer. I have used jest with other api test frameworks before so should probably give it a go myself. Its not the using of it that will cause me issues its resolving all the conflicts with current framework I am using.