New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using with LoopbackJS #107

Closed
Pentiado opened this Issue May 16, 2015 · 7 comments

Comments

Projects
None yet
2 participants
@Pentiado

Pentiado commented May 16, 2015

I'm trying to use Wallaby with LoopbackJS and last couple of hours brought only failures. Maybe someone here already figured out how to do it. Here is my wallaby config that is closest to "it's working"

module.exports = function () {
  return {
    files: [
      'server/**/*.js',
      'common/**/*.js',
      'test/global.js'
    ],
    tests: [
      'test/models/*.js',
      'test/services/*.js'
    ],
    workers: {
      recycle: true //doesn't matter whats set here
    },
    bootstrap: function (wallaby) {
      // try number 1
      if (global.app) return;
      var path = require('path');
      var loopback = require('loopback');
      var boot = require('loopback-boot');

      wallaby.delayStart();
      global.app = loopback();
      // instead of __dirname I was trying also localProjectDir and projectCacheDir
      boot(global.app, path.join(__dirname, 'server'), function () {
        wallaby.start();
      });
      // try number 2
      var path = require('path');
      if (global.app) return;
      global.app = require(path.join(wallaby.localProjectDir, 'server/server.js'));
    },
    env: {
      type: 'node',
      params: {
        env: 'NODE_ENV=test'
      }
    }
  };
};

Try number 1 starts but the app seems to be not configured. app.get('some-config') as well as app.models.myModel is always undefined.
Try number 2 seems to be a bit better because it runs some tests but it throws the same errors as first one.

@ArtemGovorov

This comment has been minimized.

Show comment
Hide comment
@ArtemGovorov

ArtemGovorov May 17, 2015

Member

Ok, I think I managed to make it work, the config is below.

I have used your second approach (changed wallaby.localProjectDir to process.cwd(), ideally it should be wallaby.projectCacheDir, but I haven't yet added this property to the bootstrap wallaby argument, will add it).

Another change I have made is changing your files patterns from **/*.js to **/*.* because there are also json files and they do participate in models and config initialisation, so wallaby needs them as well.

module.exports = function () {
  return {
    files: [
      'server/**/*.*',
      'common/**/*.*',
      'test/global.js'
    ],
    tests: [
      'test/models/*.js',
      'test/services/*.js'
    ],

    setup: function (wallaby) {
      if (global.app) return;
      var path = require('path');
      global.app = require(path.join(process.cwd(), 'server/server.js'));
    },

    env: {
      type: 'node',
      params: {
        env: 'NODE_ENV=test'
      }
    }
  };
};

Please let me know if it now works for you.

Member

ArtemGovorov commented May 17, 2015

Ok, I think I managed to make it work, the config is below.

I have used your second approach (changed wallaby.localProjectDir to process.cwd(), ideally it should be wallaby.projectCacheDir, but I haven't yet added this property to the bootstrap wallaby argument, will add it).

Another change I have made is changing your files patterns from **/*.js to **/*.* because there are also json files and they do participate in models and config initialisation, so wallaby needs them as well.

module.exports = function () {
  return {
    files: [
      'server/**/*.*',
      'common/**/*.*',
      'test/global.js'
    ],
    tests: [
      'test/models/*.js',
      'test/services/*.js'
    ],

    setup: function (wallaby) {
      if (global.app) return;
      var path = require('path');
      global.app = require(path.join(process.cwd(), 'server/server.js'));
    },

    env: {
      type: 'node',
      params: {
        env: 'NODE_ENV=test'
      }
    }
  };
};

Please let me know if it now works for you.

@ArtemGovorov

This comment has been minimized.

Show comment
Hide comment
@ArtemGovorov

ArtemGovorov May 17, 2015

Member

P.S. added wallaby.projectCacheDir, so you may use it instead process.cwd() if you like it better.

Member

ArtemGovorov commented May 17, 2015

P.S. added wallaby.projectCacheDir, so you may use it instead process.cwd() if you like it better.

@Pentiado

This comment has been minimized.

Show comment
Hide comment
@Pentiado

Pentiado May 17, 2015

Thanks! Yes, it works! I mean, tests are crashing but this time it's my fault, I think. I need to improve clean up and make them work in separation. Not that easy task when you worked on some code for months : )

Pentiado commented May 17, 2015

Thanks! Yes, it works! I mean, tests are crashing but this time it's my fault, I think. I need to improve clean up and make them work in separation. Not that easy task when you worked on some code for months : )

@Pentiado Pentiado closed this May 17, 2015

@ArtemGovorov

This comment has been minimized.

Show comment
Hide comment
@ArtemGovorov

ArtemGovorov May 17, 2015

Member

You may try to restore

workers: {
    recycle: true
}

and test environment will be recreated for each run, so some clean up may be avoided.

Some of the issues may also be fixed by removing parallelisation:

workers: {
    recycle: true,
    regular: 1, initial: 1
}

These may get you up and running quicker, though for the best wallaby performance it's better to avoid these settings by isolating tests and doing environment clean up (test fixture specific in afterEach or some global clean up in bootstrap).

Member

ArtemGovorov commented May 17, 2015

You may try to restore

workers: {
    recycle: true
}

and test environment will be recreated for each run, so some clean up may be avoided.

Some of the issues may also be fixed by removing parallelisation:

workers: {
    recycle: true,
    regular: 1, initial: 1
}

These may get you up and running quicker, though for the best wallaby performance it's better to avoid these settings by isolating tests and doing environment clean up (test fixture specific in afterEach or some global clean up in bootstrap).

@Pentiado

This comment has been minimized.

Show comment
Hide comment
@Pentiado

Pentiado May 17, 2015

Yeah, I'll try. Thanks!
After some problems at the beginning with accepting payment I managed to get my full version of WallabyJS. You guys are doing great job! Looking forward for further releases.

Pentiado commented May 17, 2015

Yeah, I'll try. Thanks!
After some problems at the beginning with accepting payment I managed to get my full version of WallabyJS. You guys are doing great job! Looking forward for further releases.

@ArtemGovorov

This comment has been minimized.

Show comment
Hide comment
@ArtemGovorov

ArtemGovorov May 17, 2015

Member

@Pentiado Thank you for your support!
What kind issues with payment did you have?

Member

ArtemGovorov commented May 17, 2015

@Pentiado Thank you for your support!
What kind issues with payment did you have?

@Pentiado

This comment has been minimized.

Show comment
Hide comment
@Pentiado

Pentiado May 18, 2015

It looks like fastspring requires to use currency of country you're located in. I wanted to use my USD credit card but it wasn't allowing me. When I tried EUR it went smoothly.

Pentiado commented May 18, 2015

It looks like fastspring requires to use currency of country you're located in. I wanted to use my USD credit card but it wasn't allowing me. When I tried EUR it went smoothly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment