SunGard-Labs / sg-protractor-tools

This library provides helper functions for the Protractor test framework. It includes functions that simplify things like browser resizing, scrolling and memory usage tracking as part of a test suite.
MIT License
25 stars 6 forks source link

Test description not passed to baseFileName variable #3

Open tediroca opened 7 years ago

tediroca commented 7 years ago

I've created the folling test:

var sgpt = require('sg-protractor-tools');

describe('Memory Test', function () {
    it('should allow me to measure memory', function () {
        var iterations = 250;
        sgpt.memory.runTestFunction(this, iterations, function () {
            console.log("Testing");
        });
    });
});

If I try to execute this single spec (named test.spec.js) this produces the following error:

C:\Users\tedi\git\proj\e2e-tests>protractor protractor-int.conf.js --specs=test.spec.js
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
Spec started

  Memory Test
    × should allow me to measure memory
      - Failed: Cannot read property 'replace' of undefined
          at C:\Users\tedi\git\proj\node_modules\sg-protractor-tools\lib\memory.js:67:74
          at Object.module.exports.startMemoryMeasurement (C:\Users\tedi\git\proj\node_modules\sg-protractor-tools\lib\memory.js:119:6)
          at Object.module.exports.runTestFunction (C:\Users\tedi\git\proj\node_modules\sg-protractor-tools\lib\memory.js:173:40)
          at Object.<anonymous> (C:\Users\tedi\git\proj\e2e-tests\test.spec.js:11:21)
          at wrappedCtr.constructor (C:/Users/tedi/AppData/Roaming/npm/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1056:7)
          at new wrappedCtr (C:\Users\tedi\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\goog\base.js:2468:26)
          at wrappedCtr.execute_ (C:/Users/tedi/AppData/Roaming/npm/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2776:14)
          at wrappedCtr.executeNext_ (C:/Users/tedi/AppData/Roaming/npm/node_modules/protractor/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2758:21)
      From: Task: Run it("should allow me to measure memory") in control flow
      From asynchronous test:
      Error
          at Suite.<anonymous> (C:\Users\tedi\git\proj\e2e-tests\test.spec.js:7:5)
          at Object.<anonymous> (C:\Users\tedi\git\proj\e2e-tests\test.spec.js:4:1)
          at Module._compile (module.js:556:32)
          at Object.Module._extensions..js (module.js:565:10)
          at Module.load (module.js:473:32)
          at tryModuleLoad (module.js:432:12)

I'm using Protractor 3.0.0 and Jasmine 2.5.1

cawo commented 7 years ago

Hi Can you confirm that you have run your test by running the server and the test in a second console As describer here : https://github.com/SunGard-Labs/sg-protractor-tools/tree/master/example

Thanks

tediroca commented 7 years ago

Hi,

I'm running the tests by directly invokating protractor and using the config below:

exports.config = {
    allScriptsTimeout: 1000000,
    directConnect: true,
    specs: ['*.spec.js'],
    capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {'args': ['lang=en-GB', 'enable-precise-memory-info', 'js-flags=--expose-gc', 'no-sandbox']}
    },
    baseUrl: 'https://mytestenvironment.com',
    framework: 'jasmine2',
    restartBrowserBetweenTests: false,
    onPrepare: function () {
        browser.manage().window().setSize(1600, 1000);
        var jasmineReporters = require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
            consolidateAll: true,
            filePrefix: 'results',
            savePath: 'reports/xml'
        }));
        var HtmlScreenshotReporter = require('protractor-jasmine2-screenshot-reporter');
        jasmine.getEnv().addReporter(new HtmlScreenshotReporter({
            dest: 'reports/html',
            filename: 'results.html'
        }));
        var SpecReporter = require('jasmine-spec-reporter');
        jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
    },
    jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 1050000,
        isVerbose: true,
        includeStackTrace: true,
        print: function () {}
    }
};

In my case the application is already deployed and running in an external server and I'm invoking each of the specs individually in order to have a more granular control of the execution results.

Thanks.

nicolasletoublon commented 7 years ago

I got exactly the same problem, running a simple test, with the server external also .. Do that library still supported ??

beatakru commented 5 years ago
  1. line from memory.js is: var baseFileName = path.join(options.dir, 'M' + test.description.replace(/\W/gi, '-') + '' + time);

So you need to declare your it in the same "test" way: const test = it('Memory Test', () => { var memoryMeasure = sgpt.memory.startMemoryMeasurement(test); }

SubJunk commented 4 years ago

I got this too, and I am using names for the describe and it blocks.

AravindKumar3992 commented 3 years ago

Issue got resolved?? If its resolved please pine me the solution