Git Product home page Git Product logo

Comments (1)

jamestalmage avatar jamestalmage commented on August 18, 2024

Take a look at the mocha branch (not yet merged).

It should handle the basic describe / it conversion. Happy to take PR's focused on Jasmine (don't worry about any CLI integration just yet).

Beware if you are doing something like this:

describe('foo', function () {
  var x;
  var y;
  beforeEach(function () {
    x = someFixture();
    y = otherFixture();
  });

  it('testA', ...);
  it('testB', ...);
});

You are going to need to change how you do things to take advantage of AVA's async nature. testA and testB will run concurrently, so accessing the shared variable is likely to cause problems. You don't have this problem in mocha, because both tests are never active together.

You could just default to test.serial, but then you miss out on async execution.

You could transition all of them to using context:

test.beforeEach(t => {
  t.context = {
    x: someFixture(),
    y: someOtherFixture()
  };
});

test('testA', t => {
  let {x, y} = t.context;
  // use x and y as you did before
});

test('testB', t => {
  let {x, y} = t.context;
  // use x and y as you did before
});

Or you could just use setup functions as recommended in the AVA recipes:

const setup = () =>  {
  x: someFixture(),
  y: someOtherFixture()
};

test('testA', t => {
  let {x, y} = setup();
  // use x and y as you did before
});

test('testB', t => {
  let {x, y} = setup();
  // use x and y as you did before
});

Neither of these help you if someFixture() or someOtherFixture() rely on global state. In that case, you probably are stuck with test.serial (or transitioning away from using global state in your app - which is better if doable).

All the above is what makes these codemods difficult, and why we haven't made a ton of progress yet.

from ava-codemods.

Related Issues (17)

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.