GithubHelp home page GithubHelp logo

Comments (15)

fatso83 avatar fatso83 commented on August 17, 2024 1

Would not dream of saying such a thing. Who uses Bower anyway these days? ;-) Just update #72 to pass the linting and this should be fixed.

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

Ah okay, I thought maybe not many folks at sinonjs were using Webpack, since sinon (before 2.0.0-pre) isn't Webpack-compatible. Working on fixing the jslint error...

from fake-timers.

fatso83 avatar fatso83 commented on August 17, 2024

Fixed by #72 (47b30ed)

from fake-timers.

fatso83 avatar fatso83 commented on August 17, 2024

I messed up when rebasing and merging in your changes, as I didn't run the linting (which failed due to migrating to ESLint where we disallowed Function calls), and I had to revert the commit.

While just disabling that eslint rule would be fine, I went on to inspect this further, seeing if the Function call was necessary or not (or if we could just use your other solution), and I devised a test script to see if thing still worked:

var lolex = require("./src/lolex-src.js");

var clock = lolex.install();
fn = function() { console.log('should show immediately'); }
setTimeout(fn, 15000); // Schedules with clock.setTimeout
clock.tick(20000);

I compiled this using webpack --output.file out.js foo.js and also created a index.html with these contents:

<script src="./out.js" ></script>

What struck me was that this works without your patch in both the browser and in Node, so I am not sure which problem you are fixing? Could you please come up with the details necessary to recreate a failing testcase in the master branch?

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

Sure, I wonder if it depends on the webpack config? I just checked and if I go into my chrome console and evaluate global I get a ReferenceError. So maybe webpack is polyfilling it? Or babel?

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

Yes, here it is: https://webpack.github.io/docs/configuration.html#node
Now to find out why that wasn't taking effect for me...

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

In any case wouldn't you want lolex-src.js to work standalone in the browser, without being built into a webpack bundle?

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

we could probably go with typeof global === 'undefined' ? this : global instead...

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

Okay, I think what happened was I was using sinon < 2.0.0 in the browser (with Karma), and since sinon < 2.0.0 is not webpackable, I was loading it and lolex as webpack externals, hence no polyfill for global was getting injected into lolex. Make sense?

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

In addition I think usage of mochify in your tests is also polyfilling global in the code that gets run in phantomjs.

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

Okay, repro is simple: just paste lolex-src.js into a Chrome console and hit enter. You'll get Uncaught ReferenceError: global is not defined(…)

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

sigh the JS world can be so confusing these days. Yes, I was trying to use lolex as a webpack external so that I could use sinon 1.7 as a webpack external. I hadn't noticed that you basically require lolex to be built with browserify or webpack to use in the browser. In any case the global || this at the bottom of lolex-src.js is probably pointless

from fake-timers.

fatso83 avatar fatso83 commented on August 17, 2024

It already does. It's in the top level directory, lolex.js, built by
Browserify on each release.

  1. jul. 2016 16.25 skrev "Andy Edwards" [email protected]:

In any case wouldn't you want lolex-src.js to work standalone in the
browser, without being built into a webpack bundle?


You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
#71 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAluXJNdmWLM00PPNUgOwZXYgNdFTRAFks5qV5hsgaJpZM4I93P2
.

from fake-timers.

jedwards1211 avatar jedwards1211 commented on August 17, 2024

Well I'm closing this as invalid. Sorry for the trouble

from fake-timers.

fatso83 avatar fatso83 commented on August 17, 2024

No worries. This does show we need to update the docs, though. I see it says you need to build it yourself, which is incorrect.

from fake-timers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.