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.

API: mock source.input.file

See original GitHub issue

I need to prevent my plugin to run on css files inside /node_modules. For that I check for the value of rule.source.input.file.

root.walkDecls(rule => {
    if (rule.source.input.file && rule.source.input.file.indexOf('/node_modules') > 0) {
       return false;
    }
   
    // ...
}

Now I want to do a Jest test with it, but the input.file is always undefined.

How do I mock it?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
aicommented, Jun 1, 2017

Add this code (replace similar code in the to of test file).

postcss([ plugin(opts) ]).process(input, { from: "test/path" })
0reactions
sandrina-pcommented, Jun 2, 2017

Hey it worked!

Thanks 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create Rest Mock API in Seconds With These 9 Tools
Are you looking for a platform to run mock REST APIs quickly and easily? Opt for Mockoon, a free and open-source platform to...
Read more >
Create mock APIs in seconds with Mockoon
Mockoon is the easiest and quickest way to design and run mock REST APIs. No remote deployment, no account required, free and open-source....
Read more >
How to Mock API Calls in Test Environments - Stoplight Blog
Stoplight has an open source mock server that generates from OpenAPI documents. ... Automated API testing is a great way to ensure the...
Read more >
How to provide mock files to change event of <input type='file ...
Here is an example spec for input file/image using angular2+. it('should call showError on toastService Api on call of onSaveOfImage() ...
Read more >
How to make a mock API server in JavaScript - Snyk
To speed up your development process, you will create a mock server. In your src directory, create a file called mock.js and add...
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