Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20949 > unrolled thread
| Started by | David Karr <davidmichaelkarr@gmail.com> |
|---|---|
| First post | 2013-08-13 16:29 -0700 |
| Last post | 2013-08-18 08:21 -0700 |
| Articles | 5 on this page of 45 — 12 participants |
Back to article view | Back to comp.lang.javascript
require.js in a phantomjs test fails for code that works fine in production David Karr <davidmichaelkarr@gmail.com> - 2013-08-13 16:29 -0700
Re: require.js in a phantomjs test fails for code that works fine in production "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-08-13 16:52 -0700
Re: require.js in a phantomjs test fails for code that works fine in production David Karr <davidmichaelkarr@gmail.com> - 2013-08-13 17:27 -0700
Re: require.js in a phantomjs test fails for code that works fine in production Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-14 11:24 +0200
Re: require.js in a phantomjs test fails for code that works fine in production John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-14 14:48 +0100
Re: require.js in a phantomjs test fails for code that works fine in production Jim T. <x@y.z> - 2013-08-14 14:32 -0400
Re: require.js in a phantomjs test fails for code that works fine in production Tim Streater <timstreater@greenbee.net> - 2013-08-14 19:43 +0100
Re: require.js in a phantomjs test fails for code that works fine in production Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-08-15 18:51 -0300
Re: require.js in a phantomjs test fails for code that works fine in production Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-16 02:28 +0200
Re: require.js in a phantomjs test fails for code that works fine in production Martin Leese <please@see.Web.for.e-mail.INVALID> - 2013-08-15 20:12 -0600
Re: require.js in a phantomjs test fails for code that works fine in production John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-16 11:29 +0100
c.l.js (was: require.js in a phantomjs test fails for code that works fine in production) Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-16 23:57 +0200
Re: c.l.js Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-18 10:17 +0200
Re: c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-18 15:14 +0100
Re: c.l.js (was: require.js in a phantomjs test fails for code that works fine in production) John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-18 15:51 +0100
Re: c.l.js Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-18 17:14 +0200
Re: c.l.js Tim Streater <timstreater@greenbee.net> - 2013-08-18 16:44 +0100
Re: c.l.js Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-18 17:52 +0200
Re: c.l.js Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-18 19:28 +0200
Re: c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-19 15:42 +0100
Re: c.l.js Andrew Poulos <ap_prog@hotmail.com> - 2013-08-20 06:58 +1000
Re: c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-20 16:10 +0100
Re: c.l.js Andrew Poulos <ap_prog@hotmail.com> - 2013-08-21 07:55 +1000
[OT] How to find messages by ID (was: c.l.js) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-21 06:47 +0200
Re: [OT] How to find messages by ID (was: c.l.js) John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-21 15:50 +0100
Re: [OT] How to find messages by ID (was: c.l.js) Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-21 23:13 +0200
Re: [OT] How to find messages by ID (was: c.l.js) John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-22 11:05 +0100
Quoting in c.l.js (was: [OT] How to find messages by ID) Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-22 15:06 +0200
Re: Quoting in c.l.js (was: [OT] How to find messages by ID) John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-24 10:05 +0100
Re: Quoting in c.l.js Christoph Michael Becker <cmbecker69@arcor.de> - 2013-09-01 22:32 +0200
Re: Quoting in c.l.js Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-09-02 00:08 +0200
Re: Quoting in c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-09-02 15:52 +0100
Re: c.l.js Christoph Michael Becker <cmbecker69@arcor.de> - 2013-08-20 01:06 +0200
Re: c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-20 16:14 +0100
Re: c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-19 16:07 +0100
Re: c.l.js Andrew Poulos <ap_prog@hotmail.com> - 2013-08-20 07:01 +1000
Re: c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-20 16:20 +0100
Re: c.l.js Andrew Poulos <ap_prog@hotmail.com> - 2013-08-21 08:02 +1000
Re: c.l.js Tim Streater <timstreater@greenbee.net> - 2013-08-20 23:29 +0100
Re: c.l.js Andrew Poulos <ap_prog@hotmail.com> - 2013-08-21 14:59 +1000
Re: c.l.js John Harris <niam@jghnorth.org.uk.invalid> - 2013-08-21 16:05 +0100
Re: c.l.js Andrew Poulos <ap_prog@hotmail.com> - 2013-08-22 07:43 +1000
[FAQ] “javascript” (was: require.js in a phantomjs test fails for code that works fine in production) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-18 11:36 +0200
Re: require.js in a phantomjs test fails for code that works fine in production Carlos Pedro <carlospedr@gmail.com> - 2013-08-15 04:28 -0700
Re: require.js in a phantomjs test fails for code that works fine in production richarduie@yahoo.com - 2013-08-18 08:21 -0700
Page 3 of 3 — ← Prev page 1 2 [3]
| From | John Harris <niam@jghnorth.org.uk.invalid> |
|---|---|
| Date | 2013-08-21 16:05 +0100 |
| Subject | Re: c.l.js |
| Message-ID | <lol919hd79c3f9qtlm5t0d3965o3iiubi2@4ax.com> |
| In reply to | #21019 |
On Wed, 21 Aug 2013 14:59:07 +1000, Andrew Poulos <ap_prog@hotmail.com> wrote: <snip> >BTW calling people names is puerile. In that case please tell Thomas to stop doing it. John
[toc] | [prev] | [next] | [standalone]
| From | Andrew Poulos <ap_prog@hotmail.com> |
|---|---|
| Date | 2013-08-22 07:43 +1000 |
| Subject | Re: c.l.js |
| Message-ID | <E6GdnUW8pJbhqYjPnZ2dnUVZ_sGdnZ2d@westnet.com.au> |
| In reply to | #21021 |
On 22/08/2013 1:05 AM, John Harris wrote: > On Wed, 21 Aug 2013 14:59:07 +1000, Andrew Poulos > <ap_prog@hotmail.com> wrote: > > > <snip> > > In that case please tell Thomas to stop doing it. Huh, you want me to tell him to stop creatively clipping posts? Andrew Poulos
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-08-18 11:36 +0200 |
| Subject | [FAQ] “javascript” (was: require.js in a phantomjs test fails for code that works fine in production) |
| Message-ID | <2377471.k03CVt3Ec2@PointedEars.de> |
| In reply to | #20960 |
Christoph Michael Becker wrote: > […] there's already a simplified definition in the newsgroup's > FAQ[1][2]: > > | The term "javascript" is used as a common name for all dialects of > | ECMAScript. > > [1] <http://jibbering.com/faq/#ecma> > [2] <http://pointedears.de/scripts/faq/cljs/#tips> Thank you for bringing this to my attention. Since the comp.lang.javascript FAQ remains unmaintained, and I have not yet received good suggestions to resolve the issue, I have updated this paragraph in the FAQ for comp.lang.javascript as follows: | For historical reasons, the term “javascript” is used herein as a | shorthand for “ECMAScript-based programming languages”. Note that not all | uses of that term here are correct. For example, there are instances where | using “DOM” instead would have been correct. This will be fixed in a later | revision. I have also made some other small adjustments. Please see the SVN changelog for details. Regards, -- PointedEars, ed. Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | Carlos Pedro <carlospedr@gmail.com> |
|---|---|
| Date | 2013-08-15 04:28 -0700 |
| Message-ID | <7b4ad082-ced6-4602-bf65-6967cd67fe7c@googlegroups.com> |
| In reply to | #20949 |
You must include the file where Data is defined in your tests like you do in the
documents you are loading to your page, otherwise Data won't be defined and
you'll get that reference error.
Hope I helped.
On Wednesday, August 14, 2013 1:29:33 AM UTC+2, David Karr wrote:
> I have a small webapp whose javascript code I don't normally maintain. I work on the back-end of the service, but that's irrelevant to the question.
>
>
>
> I'm trying to implement javascript unit tests. Someone helped me put together a configuration using maven, jstestrunner, phantomjs, and qunit, along with one trivial unit test.
>
>
>
> This configuration works, except I had to add one line of code to the CUT (code under test) that the code running in production doesn't need. It still works in production with the added line, but I need to understand why the test requires the line.
>
>
>
> In short, one of the several .js files begins like this:
>
>
>
> -------------------
>
> Data.Daily = new Function();
>
>
>
> Data.Daily.prototype = {
>
> ...
>
> -----------------
>
>
>
> When I run my test, I see this failure:
>
> -------------
>
> at http://localhost:9080/js/require.js:1703: Can't find variable: Data, source: ReferenceError: Can't find variable: Data
>
> -------------
>
>
>
> I then added the following line before the first line:
>
> -------------
>
> var Data = window.Data || {};
>
> -------------
>
>
>
> This fixes the test. Running the app in my browser works fine both with or without this line.
>
>
>
> I know I haven't provided much code here, but is there anything obvious here that I'm missing?
[toc] | [prev] | [next] | [standalone]
| From | richarduie@yahoo.com |
|---|---|
| Date | 2013-08-18 08:21 -0700 |
| Message-ID | <1c9d746d-c102-489d-b969-6bb44a5538b4@googlegroups.com> |
| In reply to | #20949 |
> I know I haven't provided much code here, but is there anything obvious here > that I'm missing? The short answer is that some script in prod includes a declaration of Data, and that declaration is missing in test (or fails to occur prior to line 1703 of require.js). That is, your prod environment includes different code than your test tier. Your solution may seem to work in prod, but it's questionable. There is some object, Data, that was intended by the original developer. There's no reliable way to conjecture from the limited info you've given as to the nature of any functions or variables associated with the originally intended Data object, but to assume it is an entirely empty object, as your "fix" does, seems risky. Presuming there IS some specific, non-empty state or behavior encapsulated in the original definition of Data, the fact that your fix works in prod indicates that your test suite fails to encompass validation of those original aspects. You need to identify why the reference doesn't fail in prod. Identify the point that Data becomes defined in prod and then repair the corresponding deficiency of your test tier. Overall, this should disquiet you about unidentified differ- ences between your prod and test tiers and possible significantly incomplete scope of your test suite. Three cases strike me as most likely: 1) a file include for a script is missing in test; 2) a file include that succeeds in prod fails in test; 3) a script differs between prod and test. I don't know what tools you use. Running diffs against the files test vs. prod might help you identify issues related to cases (1) and (3). Live interactions with the pages using a browser based debugger, e.g., Firebug, might reveal case (2) failures. "Have fun storming the castle."
[toc] | [prev] | [standalone]
Page 3 of 3 — ← Prev page 1 2 [3]
Back to top | Article view | comp.lang.javascript
csiph-web