What's wrong? I can't run my tests, because can't ...
# pact-js
a
What's wrong? I can't run my tests, because can't find pact module.
t
If you remove node-modules and do
npm install
again, do you see any errors?
I would guess that will fix it, but if not, see if the file that the error message is listing there as not found is present or not (it’s not visible in your screenshot).
Which version of pact-core is that? You can find out with
npm ls @pact-foundation/pact-core
a
Thanks for answer me. Yes, I do it. Any error, only warnings...
The version is "13.13.0"
The screenshot when I run `` npm install ``
message has been deleted
t
Sorry, that needs to be removing
node_modules
, and then running
npm install
(otherwise it doesn’t re-run install scripts)
a
Yes, I do it before. A feel times.
t
From that log you can see that it didn’t install anything, because it just says
up to date
a
Yes, sometimes it fix!!
But before I came here, I try to install again.
And didn't fix.
t
I’m asking - what is the output of npm install when you remove node_modules (and package-lock) and run
npm install
a
Ok, I can try again...
t
the output of
npm install
on its own doesn’t have any of the warnings, so we can’t use it to figure out what is happening here.
a
Ok, one moment, I'm deleting and installing again
👍 1
Done!
t
Were there other warnings above this?
a
Yes
Let me show you
t
None of that looks related. But the other warnings might be
a
message has been deleted
That's all
t
(while we’re here, you should definitely run
npm audit fix
- it won’t fix this, but I mean, that’s a lot of vulnerabilities)
hmm
a
Good! I will do it
t
Can you tell me what the error message says in your first screenshot? I’m afraid I don’t speak Spanish
Is there anything unusual about your architecture - it looks like you’re on windows - you’re not running it on some odd chipset like an Apple M1?
a
"Could not find the specified module"
t
Right, that’s what I guessed.
Does the file it mentions exist?
a
Yes, I'm! Does Pact works on windows?
t
For example, if I install that exact version on my machine, that file exists:
message has been deleted
Yes, Pact should work on Windows
a
What file should exist ? Sorry, I didn't understand
t
The error message is complaining about not being able to find
node_modules/@pact-foundation/pact-core/build/Release/pact.node
a
Right
Let me see
t
Either the file isn’t there (I don’t know if it’s built on install or not - I’m a bit out of touch with 10.x / 13.x core)
or it isn’t being picked up by node
oh, which version of node are you on?
you can tell with
node --version
a
message has been deleted
My node version is v16.14.0
t
That should work.
a
I've been trying for days to resolve this. 😵‍💫
t
oof, that’s very frustrating
a
Yes! Just another normal day in the life of IT...🤣
I hope it works. I really want to introduce contract tests to my team.
t
oh, I wonder if this is a jest problem
that’s not node failing, that’s Jest
a
Eureka! I see a light at the end of the tunnel.
🙏
t
Are you able to share this project, or at least a minimal set that reproduces this problem?
Also, other things to try - what happens if you upgrade to the latest jest/ts-jest, and the latest node 16.x (which I think is 16.19)
good to eliminate those
a
Yes, of course.
t
Same with pact - try 10.4.0
I don’t think that will fix the issue directly, but maybe there’s something small that got fixed
a
Ok! Sure.
I agree with you, the problem is with Jest. I put "node" as a module name mapper config and now it could find the module
But other error appear
I will change the versions, one moment.
t
Right, so that will tell it to look in the mocks for anything with a
node
suffix. So that won’t work.
a
😥
t
The jest config looks right.
(assuming that you remove the
node
bit again)
👍 1
a
Please, send me your email github, I will put you as a collaborator in my project
It's just a small project I created to try to write contract tests
👍 1
This is the consumer, that I'm trying to write the tests first
And the provider I didn't try yet: https://github.com/amandaremessa/provider
t
Ok, so there was a mix of a lot of different styles of code - some of it was incompatible.
For example, you had jest tests, but with mocha syntax
I’ve fixed these issues in a PR here: https://github.com/amandaremessa/consumer/pull/3
So, my machine is a mac, and the tests pass with that exact version of node
I’m trying a run on github’s windows runners to eliminate that as a problem
it looks successful so far
1
Ah, it failed, but that’s because the promise returned in the setup wasn’t waited for. I fixed that here: https://github.com/TimothyJones/consumer/actions/runs/3935242418
Try: 1) Merging that PR I sent you 2) Upgrading to node 16.19.0
❤️ 1
If you’re still having problems, I suspect it’s something to do with the babel config, since there’s a mix of
import
and
require
a
It's late around here, so tomorrow I'll make the changes you pointed out there. But I'm new to Pac and ended up following different tutorials and that's why there was all this confusion!
I do not know how to thank you. Thank you a lot!!
t
You’re welcome!
Let us know how you go
a
I'll make the changes tomorrow and let you know if it worked.
Thanks for the help! You are amazing! ❤️
Hey @Timothy Jones Now my consumer test is working ! Thank you a lot!
I'm so happy! ☺️
🙌 1
t
Awesome! Glad to help!
🙏 1
❤️ 1
a
@Timothy Jones My first contract test is working on provider side! YAY 😄
🙌 1