karma-runner / karma-chrome-launcher

A Karma plugin. Launcher for Chrome and Chrome Canary.
MIT License
467 stars 120 forks source link

Utilizing Filesystem API #36

Open summera opened 9 years ago

summera commented 9 years ago

Having a bit of trouble getting the filesystem api to work with the chrome launcher. Any suggestions for configuring this? Thanks!

dignifiedquire commented 9 years ago

Could you describe the issue you are having in a little more detail please?

summera commented 9 years ago

@Dignifiedquire sure thing.

I was attempting to test a package I wrote, which is a thin wrapper around chrome's filesystem api. I was writing some tests for the library which would write directories and files to chrome's persistent file storage and check if they were there. I tried using karma-chrome-launcher for this, but it didn't seem to get along with the filesystem api.

Test looks something like the following:

describe("Chromestore", function() {
  'use strict';

  var cs = null;

  before(function() {
    cs = new ChromeStore([
      { path: 'videos/clips' },
      { path: 'audio/wav' }
    ]);

    cs.init(1024*1024*1024, function() {
      done();
    });
  });

  it('returns the correct used and remaining bytes', function() {
    cs.usedAndRemaining(function(used, remaining) {
      expect(used).to.equal(0);
      expect(remaining).to.equal(1024*1024*1024);
      done();
    });
  });
});

I also tried configuring karma-chrome-launcher like so:

module.exports = function (config) {
  config.set({
    basePath: '',

    frameworks: ['mocha', 'chai'],

    files: [
      'src/*.js',
      'test/*.spec.js'
    ],

    reporters: ['progress'],

    port: 9876,
    colors: true,
    autoWatch: false,
    singleRun: true,

    logLevel: config.LOG_DEBUG,

    browsers: ['chrome_without_security'],

    customLaunchers: {
      chrome_without_security: {
        base: 'Chrome',
        flags: ['--disable-web-security']
      }
    }
  });
};

It's been a while since I've thought about this so hope this provides you enough information.