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.

global.webpack_isomorphic_tools creates an error on mocha

See original GitHub issue

I’m having trouble with this setup running on mocha even after adding --globals webpack_isomorphic_tools on my cli

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
catamphetaminecommented, Aug 31, 2016

Without you telling what file exactly are you running with mocha I will be closing this issue

0reactions
mateeyowcommented, Aug 31, 2016

It has something to do with my integration testing and since my controller is required by my main app it was read by mocha.

...
// return next()
  if (__DEVELOPMENT__) {
    webpack_isomorphic_tools.refresh()
  }

  const routes = createRoute()
  const store = configureStore()
  match({ routes, location: req.url }, (err, redirect, props) => {
    if (err) {
      res.status(500).send(err.message)
    } else if (redirect) {
      res.redirect(302, redirectLocation.pathname + redirectLocation.search)
    } else if (props) {
      const component = (
        <Provider store={store}>
          <RouterContext {...props} />
        </Provider>
      )

      res.status(200).send('<!doctype html>\n' +
        renderToString(<Html 
          assets={webpack_isomorphic_tools.assets()}
          component={component}
          store={store}
        />)
      )
    } else {
      res.status(404)
    }
  })

And oh! DEVELOPMENT is global too it also gets an error

Read more comments on GitHub >

github_iconTop Results From Across the Web

self is not defined when running mocha tests in command line ...
import fetch from 'isomorphic-fetch';. The moment I have this line, my mocha tests crash with -- referenceerror: self is not defined -- error....
Read more >
Webpack build error - node.js - Stack Overflow
Strange workaround: I zipped my entire node_modules map and transfered it to PC_A and placed it correctly. Now webpack builds just fine. So...
Read more >
What does it take to support Node.js ESM? – The Guild
The only workaround to have an isomorphic __dirname or __filename to be used for both "cjs" and "esm" without using build-time tools like ......
Read more >
serverless-bundle - npm Package Health Analysis - Snyk
An extension of the serverless-webpack plugin that bundles your ES6 + TypeScript Node.js Lambda functions. For more information about how to use this ......
Read more >
Developing isomorphic applications using webpack - Medium
Lets start with the “Hello, World” and build on that example. Our example is a React application. It uses react-dom to render ReactElement...
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