cucumber / cucumber-js

Cucumber for JavaScript
https://cucumber.io
MIT License
5.05k stars 1.09k forks source link

Importing the public cucumber API is slow #2115

Open Korijn opened 2 years ago

Korijn commented 2 years ago

🤔 What's the problem you're trying to solve?

Importing @cucumber/cucumber in test setup or step modules (ES modules) takes about 4 seconds. That's waiting time before the test suite begins to run.

import { Given, When, Then } from '@cucumber/cucumber'

When I run cucumber-js as a subprocess with blank config and no step/setup code, it takes about 400 ms to exit. When I import just a single module that imports @cucumber/cucumber the time jumps up to approximately 4.4 secs.

✨ What's your proposed solution?

Is it possible to restructure the library such that the public API (hooks and step definers) can be imported without also importing every other module in cucumber? I guess that should reduce the import footprint by a lot!

⛏ Have you considered any alternatives or workarounds?

N/A

📚 Any additional context?

I'm running this on a high powered machine with an NVME SSD, so I doubt it's my machine that's slowing this down.

davidjgoss commented 2 years ago

Thanks for reporting @Korijn. We can certainly do some profiling and see where that time is going.

michael-lloyd-morris commented 1 year ago

I'm going to take a look at this. No promises.