question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: Watch mode should rerun affected specs when a file in filesToWatch changes

See original GitHub issue

Is your feature request related to a problem? Please describe. I’m disappointed when I run in watch mode and I save one of my page objects that is configured in filesToWatch but nothing happens. No specs rerun.


Describe the solution you’d like I would like to analyze the dependency graph to determine what specs use a file that is saved.

Analyzing the dependency graph of all the specs that are being run is an expensive action but that’s OK (to me). It is an acceptable tradeoff compared to finding and saving the spec to trigger the next run.

Analyzing the dependency graph requires knowledge about how the compiler is configured. We don’t need to solve this problem. If we can provide sane defaults and allow the user to override the behaviour, it’ll be “good enough”.

This does not need to be a breaking change. We can allow users to opt-in by adding a new property in the config file. I would like to be able to modify the chokadir.watch 'change' event handler so we can handle filesToWatch to watch differently. We will also need to update the run method to expect one or more specs to rerun.

I’d propose implementing this in 2 phases:

  1. Make it an extensible behaviour
  • Add a new configuration property that is a function that overrides the behaviour of getFileListener(false). I can have a signature like (configFile, specs, fileThatChanged) => spec[]
  • Refactor watcher.js to handle more than one spec being passed to run
  1. Provide examples of it working, maybe, as a third-party package?
  • Document how to traverse the dependency graph with Babel
  • Document how to traverse the dependency graph with TypeScript
  • Document the gotchas.

Thoughts on an implementation:

  • We want to use a tool to parse the code instead of evaluate it to avoid causing side effects.
  • The MVP demo is to parse import statements. They have constant module names. This makes it easy to build a depth-first search across a dependency graph from our specs to the file that was saved.
  • We/I need to be mindful of CommonJS require and dynamic import() statements that can be variable. We’re all guilty of doing something like const env = require(`config/${env}.json`) at some point.

Describe alternatives you’ve considered

  • N/A

Additional context

  • At a minimum, I’m keen to make this an extensible behaviour so I can hack at night and have a slightly better developer experience in my day job. 😉
  • Link back to gitter.im. Thanks for the reply Christian.
  • The flow through wdio-cli/src/watcher.js:
    • If filesToWatch is in the config, we register a 'change' event listener for chokadir.watch to call this.getFileListener with passOnFile set to false
    • getFileListener returns a function that calls this.run({ ...this.args }) with no spec
    • run calls this.getWorkers using a conditional pickFn
  • A great video showing an approach (without cycle detection) - https://www.wix.engineering/post/build-your-own-webpack-in-30-minutes

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
christian-bromanncommented, Sep 16, 2020

@jags14385 please do!

2reactions
jags14385commented, Sep 16, 2020

Can I pick this issue up ? Technically , would be my 2nd issue ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · webdriverio/webdriverio · GitHub
Feature request : Watch mode should rerun affected specs when a file in filesToWatch changes Enhancement. #5668 opened Jul 28, 2020 by seanpoulter....
Read more >
Watch Test Files | WebdriverIO
With the WDIO testrunner you can watch files while you are working on them. They automatically rerun if you change either something in...
Read more >
Can rspec be configured to only run tests what have been ...
Just run retest , and it will watch for changes in the code or the specs themselves, and rerun just the respective spec...
Read more >
How to Run Changed Specs First in a Pull Request - Cypress
Imagine a large project with hundreds of Cypress spec files. If you work on just one feature and open a pull request with...
Read more >
Feature Requests - SmartBear Community
When trying to Pull changes from git, setting.xml needs to be ... In ReadyAPI the random values could be available via: expansion e.g. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found