1 | var chai = require('chai');
|
2 | var expect = chai.expect;
|
3 | var testFramework = require('../index');
|
4 | var TestRun = testFramework.TestRun;
|
5 |
|
6 | describe('TestRun class', function() {
|
7 | var run;
|
8 |
|
9 | beforeEach(function() {
|
10 | run = new TestRun({
|
11 | sauceBrowserSettings: {
|
12 | resolutions: ['10_x_10'],
|
13 | id: 'rowdy_browser_id',
|
14 | other: true
|
15 | },
|
16 | sauceSettings: {
|
17 | useTunnels: true
|
18 | },
|
19 | tunnelId: 'TUNN_ID',
|
20 | mockingPort: 10,
|
21 | seleniumPort: 4444,
|
22 | locator: {
|
23 | name: 'The full name of the test to run'
|
24 | }
|
25 | });
|
26 | });
|
27 |
|
28 | it('instantiates', function() {
|
29 |
|
30 | var run = new TestRun({
|
31 | prop: true,
|
32 | environmentId: 'chrome'
|
33 | });
|
34 | expect(run.prop).to.be.true;
|
35 | expect(run.rowdyBrowser).to.equal('local.chrome');
|
36 | expect(run.sauceBrowserSettings).to.be.an('object');
|
37 | });
|
38 |
|
39 | it('instantiates with saucelabs settings', function() {
|
40 | expect(run.sauceBrowserSettings).to.not.have.property('resolutions');
|
41 | expect(run.sauceBrowserSettings).to.not.have.property('id');
|
42 | expect(run.rowdyBrowser).to.equal('sauceLabs.rowdy_browser_id');
|
43 | expect(run.tunnelId).to.equal('TUNN_ID');
|
44 | });
|
45 |
|
46 | it('returns path to mocha', function() {
|
47 | expect(run.getCommand()).to.equal('./node_modules/.bin/mocha');
|
48 | });
|
49 |
|
50 | it('returns the environment for a run', function() {
|
51 | var env = run.getEnvironment({
|
52 | NODE_CONFIG: {foo: 'bar'}
|
53 | });
|
54 |
|
55 |
|
56 | expect(env).to.deep.equal({
|
57 | MOCKING_PORT: 10,
|
58 | FUNC_PORT: 10,
|
59 | desiredCapabilities: {other: true},
|
60 | NODE_CONFIG: '{"foo":"bar","MOCKING_PORT":10,"FUNC_PORT":10,"desiredCapabilities":{"other":true}}',
|
61 | ROWDY_SETTINGS: 'sauceLabs.rowdy_browser_id',
|
62 | ROWDY_OPTIONS: '{"server":{"port":4444},"client":{"port":4444}}',
|
63 | SAUCE_CONNECT_TUNNEL_ID: 'TUNN_ID'
|
64 | });
|
65 | });
|
66 |
|
67 | it('returns the arguments for a run', function() {
|
68 | testFramework.initialize({
|
69 | 'mocha_tests': ['path/to/specs', 'another/path/to/specs'],
|
70 | 'mocha_opts': 'path/to/mocha.opts'
|
71 | });
|
72 |
|
73 | var args = run.getArguments();
|
74 | expect(args).to.deep.equal([
|
75 | '--mocking_port=10',
|
76 | '--worker=1',
|
77 | '-g',
|
78 | 'The full name of the test to run',
|
79 | '--opts',
|
80 | 'path/to/mocha.opts',
|
81 | 'path/to/specs',
|
82 | 'another/path/to/specs'
|
83 | ]);
|
84 | });
|
85 | });
|