Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion global before/after/beforeEach/afterE ach?

Received: by 10.42.57.79 with SMTP id c15mr11505857ich.33.1346861406605;
        Wed, 05 Sep 2012 09:10:06 -0700 (PDT)
X-BeenThere: mochajs@googlegroups.com
Received: by 10.231.55.155 with SMTP id u27ls1251259ibg.8.gmail; Wed, 05 Sep
 2012 09:10:05 -0700 (PDT)
Received: by 10.50.171.102 with SMTP id at6mr5976424igc.1.1346861405018;
        Wed, 05 Sep 2012 09:10:05 -0700 (PDT)
Received: by 10.50.171.102 with SMTP id at6mr5976422igc.1.1346861404983;
        Wed, 05 Sep 2012 09:10:04 -0700 (PDT)
Return-Path: <tjholoway...@gmail.com>
Received: from mail-ie0-f174.google.com (mail-ie0-f174.google.com [209.85.223.174])
        by gmr-mx.google.com with ESMTPS id dd6si749118igc.0.2012.09.05.09.10.04
        (version=TLSv1/SSLv3 cipher=OTHER);
        Wed, 05 Sep 2012 09:10:04 -0700 (PDT)
Received-SPF: pass (google.com: domain of tjholoway...@gmail.com designates 209.85.223.174 as permitted sender) client-ip=209.85.223.174;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of tjholoway...@gmail.com designates 209.85.223.174 as permitted sender) smtp.mail=tjholoway...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-ie0-f174.google.com with SMTP id e11so1618381iej.5
        for <mochajs@googlegroups.com>; Wed, 05 Sep 2012 09:10:04 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:sender:in-reply-to:references:date
         :x-google-sender-auth:message-id:subject:from:to:content-type;
        bh=UbaGYwD/n4zytV8vWkZ4L/42DEu9JlFB4kgQ2P+tXW4=;
        b=WsbY3PCCZ0i5SPyLHLXT2yPXP+wo+J2EgM9jG51xq9gMJUAytU0lWSEluSR/Dc/EMr
         bXfOFRLJbsQKqulf//yDDVsnYxqYWC7XOsmDcEQp3tMi6TntVWpQzBjHBqlMT9OhFKgF
         exYzmaYQGSH+vJtp72P/N/90FSwyDrRtS0+LWYoBsBAnG0i555D7aVr67EWDVtxg7jOV
         k/zq/rp96Pebk0n7iKK4vdncVnbzVxCjCrcwX95cJ5PxFcW81iBW6nE3xqRc0hd8Ps1y
         d4TMWg2hBN0L4vvGpytJ8cN5MI315go1LrCC2UiNEHMqyO0UyeOiNN1TSuvR1waI3Sip
         Tltg==
MIME-Version: 1.0
Received: by 10.50.194.130 with SMTP id hw2mr18688596igc.64.1346861404732;
 Wed, 05 Sep 2012 09:10:04 -0700 (PDT)
Sender: tjholoway...@gmail.com
Received: by 10.64.32.168 with HTTP; Wed, 5 Sep 2012 09:10:04 -0700 (PDT)
In-Reply-To: <65ed689b-6fc1-454f-90b3-8e4364e18121@googlegroups.com>
References: <b9023738-3221-4f29-a2f2-ca9cbf9d5560@googlegroups.com>
	<CAO5niE2T9cty4rVY_haTS7hCRL_jOmA6Sf44wUCAte3CPdf...@mail.gmail.com>
	<af9e7934-29a8-4868-8370-46928b37012c@googlegroups.com>
	<CAO5niE3feD+L+s4OY8dWpzBdNYGXT=kbfX80vOMQYZ3BJvF...@mail.gmail.com>
	<3635e98b-4769-492c-a0e4-eec694049d8f@googlegroups.com>
	<460b87b9-0b47-4267-8ddb-b58281b2d33c@googlegroups.com>
	<CAO5niE1p-Q5fZVU+gWCiyKfmj8t=Ujb_rz1JiZCrvGtmcd7...@mail.gmail.com>
	<65ed689b-6fc1-454f-90b3-8e4364e18121@googlegroups.com>
Date: Wed, 5 Sep 2012 09:10:04 -0700
Message-ID: <CAO5niE1E_Ti6+Wtqdxed3AujWs1J5CLqkfhfUmsxtQ06ZCY...@mail.gmail.com>
Subject: Re: global before/after/beforeEach/afterEach?
From: "vision media [ Tj Holowaychuk ]" <t...@vision-media.ca>
To: mochajs@googlegroups.com
Content-Type: multipart/alternative; boundary=14dae9340bc7973eb804c8f69b44

--14dae9340bc7973eb804c8f69b44
Content-Type: text/plain; charset=ISO-8859-1

added a mention to it :D

On Wed, Sep 5, 2012 at 8:43 AM, deitch <a...@deitcher.net> wrote:

> Dang, TJ, this is great! If I have a file in there that has before/after
> *outside* of any describe(), then the before gets run before any describe,
> and the after before any after.
>
> If I have a file that has beforeEach/afterEach *outside* of any
> describe(), then the beforeEach gets run before every single test, all the
> way into recursion, and the afterEach after every single test.
>
> You really need to document this on http://visionmedia.github.com/mocha,
> it is very powerful.
>
>
> On Wednesday, September 5, 2012 6:30:50 PM UTC+3, vision media [ Tj
> Holowaychuk ] wrote:
>
>> just pick any file and put beforeEach(function(){}) in it etc, it'll be
>> invoked per test-case
>>
>> On Wed, Sep 5, 2012 at 2:36 AM, deitch <a...@deitcher.net> wrote:
>>
>>> I tried recursive subdirs, but that just loads them all. Did you mean to
>>> do it programmatically, by having my root file load all the other files
>>> (i.e. replicate what addFile and loadFiles do in mocha)?
>>>
>>>
>>> On Tuesday, September 4, 2012 6:37:43 PM UTC+3, deitch wrote:
>>>>
>>>> Time for me to show my ignorance. How do I do that? I though it just
>>>> runs all files in ./tests/ and that's it. Didn't know of root and that it
>>>> can automatically include others.
>>>>
>>>> Can you give me a sample?
>>>>
>>>> On Tuesday, September 4, 2012 6:34:08 PM UTC+3, vision media [ Tj
>>>> Holowaychuk ] wrote:
>>>>>
>>>>> yeah you can do that, what I'm saying is there's one "root" suite
>>>>> regardless of how many files you have, before/after etc at the root-level
>>>>> are added to that root suite
>>>>>
>>>>> On Tue, Sep 4, 2012 at 8:33 AM, deitch <a...@deitcher.net> wrote:
>>>>>
>>>>>> Kind of restrictive if I have all one file. I have a lot of tests,
>>>>>> want to break them up by file.
>>>>>>
>>>>>>
>>>>>> On Tuesday, September 4, 2012 6:31:46 PM UTC+3, vision media [ Tj
>>>>>> Holowaychuk ] wrote:
>>>>>>
>>>>>>> yeah just have one file and put before/after etc in it, if they're
>>>>>>> at the root-level they run for everything
>>>>>>>
>>>>>>> On Tue, Sep 4, 2012 at 3:54 AM, deitch <a...@deitcher.net> wrote:
>>>>>>>
>>>>>>>> Is there any way to do a global (i.e. across all files in ./tests/)
>>>>>>>> before/after/beforeEach/**afterE****ach?
>>>>>>>>
>>>>>>>>  Let's say my tests dir looks like:
>>>>>>>>
>>>>>>>> you.js
>>>>>>>> me.js
>>>>>>>> him.js
>>>>>>>> her.js
>>>>>>>>
>>>>>>>> Before *any* of the tests in any of the files run, I have a
>>>>>>>> "global" before that will start various servers (this is for integration
>>>>>>>> testing, as opposed to stubbed units); after *all* of them are
>>>>>>>> complete, I have a "global" after that shuts them down.
>>>>>>>>
>>>>>>>> Before *each* of the tests in any files runs, I have a "global"
>>>>>>>> beforeEach that resets various data; after *each* of the tests
>>>>>>>> runs, I have a "global" afterEach (although this is less necessary).
>>>>>>>>
>>>>>>>> I could, in theory, run mocha programmatically, run my global
>>>>>>>> before before calling mocha.run(), and pass my global after to the callback
>>>>>>>> of mocha.run(callback). But it would be nice to do this using the standard
>>>>>>>> setup.
>>>>>>>> Similarly, I could wrap the entire set in each you.js, me.js, etc.
>>>>>>>> test file by calling the same beforeEach which I require from another file,
>>>>>>>> but it would be nice to do it using the standard setup.
>>>>>>>>
>>>>>>>> Or am I thinking about this the wrong way?
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>

--14dae9340bc7973eb804c8f69b44
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

added a mention to it :D<br><br><div class=3D"gmail_quote">On Wed, Sep 5, 2=
012 at 8:43 AM, deitch <span dir=3D"ltr">&lt;<a href=3D"mailto:avi@deitcher=
.net" target=3D"_blank">a...@deitcher.net</a>&gt;</span> wrote:<br><blockquo=
te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so=
lid;padding-left:1ex">
Dang, TJ, this is great! If I have a file in there that has before/after *o=
utside* of any describe(), then the before gets run before any describe, an=
d the after before any after.<div><br></div><div>If I have a file that has =
beforeEach/afterEach *outside* of any describe(), then the beforeEach gets =
run before every single test, all the way into recursion, and the afterEach=
 after every single test.</div>
<div><br></div><div>You really need to document this on <a href=3D"http://v=
isionmedia.github.com/mocha" target=3D"_blank">http://visionmedia.github.co=
m/mocha</a>, it is very powerful.<div class=3D"im"><br><br>On Wednesday, Se=
ptember 5, 2012 6:30:50 PM UTC+3, vision media [ Tj Holowaychuk ] wrote:</d=
iv>
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div class=3D"im">just pick any fil=
e and put beforeEach(function(){}) in it etc, it&#39;ll be invoked per test=
-case<br>
<br></div><div><div class=3D"h5"><div class=3D"gmail_quote">On Wed, Sep 5, =
2012 at 2:36 AM, deitch <span dir=3D"ltr">&lt;<a>a...@deitcher.net</a>&gt;<=
/span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">I tried recursive subdirs, but that just loa=
ds them all. Did you mean to do it programmatically, by having my root file=
 load all the other files (i.e. replicate what addFile and loadFiles do in =
mocha)?<div>

<div><br><br>On Tuesday, September 4, 2012 6:37:43 PM UTC+3, deitch wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border=
-left:1px #ccc solid;padding-left:1ex">Time for me to show my ignorance. Ho=
w do I do that? I though it just runs all files in ./tests/ and that&#39;s =
it. Didn&#39;t know of root and that it can automatically include others.<d=
iv>

<br></div><div>Can you give me a sample?<br><br>On Tuesday, September 4, 20=
12 6:34:08 PM UTC+3, vision media [ Tj Holowaychuk ] wrote:<blockquote clas=
s=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc =
solid;padding-left:1ex">

yeah you can do that, what I&#39;m saying is there&#39;s one &quot;root&quo=
t; suite regardless of how many files you have, before/after etc at the roo=
t-level are added to that root suite<br><br><div class=3D"gmail_quote">On T=
ue, Sep 4, 2012 at 8:33 AM, deitch <span dir=3D"ltr">&lt;<a>a...@deitcher.n=
et</a>&gt;</span> wrote:<br>


<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Kind of restrictive if I have all one file. =
I have a lot of tests, want to break them up by file.<div><br><br>
On Tuesday, September 4, 2012 6:31:46 PM UTC+3, vision media [ Tj Holowaych=
uk ] wrote:</div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin=
-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div>yeah just hav=
e one file and put before/after etc in it, if they&#39;re at the root-level=
 they run for everything<br>


<br></div><div><div class=3D"gmail_quote">On Tue, Sep 4, 2012 at 3:54 AM, d=
eitch <span dir=3D"ltr">&lt;<a>a...@deitcher.net</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Is there any way to do a global (i.e. across=
 all files in ./tests/) before/after/beforeEach/<u></u>afterE<u></u><u></u>=
ach?<div>

<br>
</div><div>
Let&#39;s say my tests dir looks like:</div><div><br></div><div>you.js</div=
><div>me.js</div><div>him.js</div><div>her.js</div><div><br></div><div>Befo=
re <b>any</b>=A0of the tests in any of the files run, I have a &quot;global=
&quot; before that will start various servers (this is for integration test=
ing, as opposed to stubbed units); after <b>all</b>=A0of them are complete,=
 I have a &quot;global&quot; after that shuts them down.</div>



<div><br></div><div>Before <b>each</b>=A0of the tests in any files runs, I =
have a &quot;global&quot; beforeEach that resets various data; after <b>eac=
h</b>=A0of the tests runs, I have a &quot;global&quot; afterEach (although =
this is less necessary).</div>



<div><br></div><div>I could, in theory, run mocha programmatically, run my =
global before before calling mocha.run(), and pass my global after to the c=
allback of mocha.run(callback). But it would be nice to do this using the s=
tandard setup.</div>



<div>Similarly, I could wrap the entire set in each you.js, me.js, etc. tes=
t file by calling the same beforeEach which I require from another file, bu=
t it would be nice to do it using the standard setup.</div><div><br></div>



<div>Or am I thinking about this the wrong way?</div></blockquote></div><br=
>
</div></blockquote></blockquote></div><br>
</blockquote></div></blockquote></div></div></blockquote></div><br>
</div></div></blockquote></div></blockquote></div><br>

--14dae9340bc7973eb804c8f69b44--