pact-foundation / pact-js-core

Core binaries for pact-js, a Contract Testing Framework. NOTE: If you are looking to do Pact contract testing in node, you almost certainly want pact-js, not pact-node.
https://docs.pact.io
MIT License
150 stars 79 forks source link

cannot load such file -- pact/mock_service/request_handlers/base_administration_request_handler #200

Closed Christoph-Raab closed 4 years ago

Christoph-Raab commented 4 years ago

Software versions

Expected behaviour

Contract tests run with jest

Actual behaviour

The project is setup like this: https://github.com/pact-foundation/pact-js/tree/master/examples/jest

On running: jest --runInBand --setupFiles ./pact/pactSetup.js --setupTestFrameworkScriptFile=./pact/pactTestWrapper.js

I get the error message (see detailed log below): cannot load such file -- pact/mock_service/request_handlers/base_administration_request_handler (LoadError)

Afterwards the test suite fails because: TypeError: Cannot read property 'writePact' of undefined

[INFO] 
[INFO]       3 | beforeAll(() => provider.setup())
[INFO]       4 | 
[INFO]     > 5 | afterAll(() => provider.finalize())
[INFO]         |                         ^
[INFO]       6 | 

I am aware of this issue: https://github.com/pact-foundation/pact-node/issues/100,

but enabling long path did nothing.

Steps to reproduce

I am running the build inside the https://github.com/eirslett/frontend-maven-plugin and call the npm run test commant like this:

<execution>
    <id>npm build</id>
    <goals>
        <goal>npm</goal>
    </goals>
   <phase>generate-resources</phase>
  <configuration>
      <arguments>run test</arguments>
  </configuration>
</execution>

This works in principle, since I can run other tests with jest with this command. For testing, all other tests are disabled, I only run the contract test.

When I delete the node_modules folder and run within wsl2:

This works. It's only inside the frontend-maven-plugin. Inside the frontend-maven-plugin runs the npm install command, which downloads the binaries for win32:

Installing Pact Standalone Binary for win32.
[INFO] Downloading Pact Standalone Binary v1.72.2 for platform win32 from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.72.2/pact-1.72.2-win32.zip

When I browse to pact/mock_service/request_handlers inside node_module, there is a base_administration_request_handler.rb file

Any ideas?

Detailed log

INFO: pact-node@10.2.2/19320 on xyz: [INFO] Creating Pact Server with options: [INFO] {"consumer":"MyClient","cors":false,"dir":"...} [INFO] ERROR: Process "15732" not found. [INFO] [2019-11-29T07:32:30.393Z] ERROR: pact-node@10.2.2/19320 on en-pc-066: [INFO] Pact Binary Error: D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/request_handlers/interaction_post.rb:1:in require': cannot load such file -- pact/mock_service/request_handlers/base_administration_request_handler (LoadError) [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/request_handlers/interaction_post.rb:1:in<top (required)>' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/request_handlers.rb:1:in require' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/request_handlers.rb:1:in<top (required)>' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/app.rb:6:in require' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/app.rb:6:in<top (required)>' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/run.rb:2:in require' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/run.rb:2:in<top (required)>' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/cli.rb:33:in require' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.2.0/lib/pact/mock_service/cli.rb:33:inservice' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in run' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:ininvoke_command' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in dispatch' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:instart' [INFO] from D:/projects/.../frontend/node_modules/@pact-foundation/pact-node/standalone/win32-1.72.2/lib/app/pact-mock-service.rb:15:in `

' [INFO]
[INFO] [2019-11-29T07:32:30.457Z] WARN: pact-node@10.2.2/19320 on xyz: Pact exited with code 1.

TimothyJones commented 4 years ago

Can you try building the project in a shallower path? (this will help confirm that it is indeed the long path issue).

Christoph-Raab commented 4 years ago

I set up a project in C:\testd, instead of now it works.

Also I counted letters of the original path, it is more than 263.

I also figured, that I might have to enable longPaths in the Admin Templates of Computer Configuration as mentioned here: https://stackoverflow.com/questions/27680647/does-max-path-issue-still-exists-in-windows-10

I did that, but it still doesn't work.

Any other ideas?

bethesque commented 4 years ago

If it is indeed the 'too long path' issue, we don't have a fix at the moment I'm afraid. We are working on an alternative to the pact-ruby-standalone, however, we don't have an expected finish date yet.

mefellows commented 4 years ago

Any other ideas?

Use a Linux VM? Or Docker?

Christoph-Raab commented 4 years ago

If it is indeed the 'too long path' issue, we don't have a fix at the moment I'm afraid. We are working on an alternative to the pact-ruby-standalone, however, we don't have an expected finish date yet.

Ok, thanks, that's bad.

Use a Linux VM? Or Docker?

I would have to set this up and everyone in my team. Bit much overhead just to use a dependency.

But ok, than I guess I have to rethink and/or wait for the release of the new standalone

snukone commented 2 years ago

In my case the path of the project under windows was just too long. To solv this i had to copy the project to a directory which wasnt that much nested as before (i.e. C:\myproject).