Blocks with shared variable scopes?

Gus Caplan me at gus.host
Thu May 28 17:54:05 UTC 2020


I would either tweak the framework:

describe('thing', () => {
  provide(() => new Thing());
  it('does one thing', (thing) => {
    thing.oneThing();
  });
  it('does other things', (thing) => {
    thing.otherThings();
  });
});

or just explicitly do `const thing = new Thing()` in each test.

On Thu, May 28, 2020 at 12:36 PM Mohsen Azimi <me at azimi.me> wrote:

> Hi,
>
> I was looking at our test code and noticed we do this variable declaration
> gymnastic to get it to work:
>
> describe('thing', () => {
> let thing: Thing;
> beforeEach(() => {
> thing = new Thing()
> })
> it('does one thing', () => {
> thing.oneThing()
> })
> it('does other things', () => {
> thing.otherThings()
> })
> })
>
> To me, the declaration of thing and binding it in the beforeEach block
> seemed kind of weird. In an ideal world I would declare thing in my
> beforeEach block and via language features communicate that scope of
> beforeEach's callback and describe's callback above should be the same.
>
> Has this come up before? Has there been proposals to address this issue?
> --
> Mohsen Azimi
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20200528/6b540a86/attachment-0001.html>


More information about the es-discuss mailing list