Skip to content
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

Uiveri5 with Karma #262

Open
uxkjaer opened this issue Dec 3, 2020 · 2 comments
Open

Uiveri5 with Karma #262

uxkjaer opened this issue Dec 3, 2020 · 2 comments
Labels
question Further information is requested

Comments

@uxkjaer
Copy link
Member

uxkjaer commented Dec 3, 2020

Hi,

I'm looking into code coverage and want to get coverage for my uiveri5 tests.

I've done it with a "hack" now using ui5-middleware-code-coverage which does work. I'm the author of this npm package as well and are currently refactoring it to get it working with NYC instead of istanbul. But this is causing me some grief.

Then I thought we could use Karma to generate the reporting using existing plugins. I can see that jasmine can run using karma. But I'm not sure about uiveri5. Hence the question.

Can uiveri5 run with Karma or is there any intention of building that functionality?

@uxkjaer
Copy link
Member Author

uxkjaer commented Dec 3, 2020

Alright so a small update from my own side. I've added this to my karma.conf.js file
`module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),

  ],
  files: [  
	'*spec.js'  
	],  
  client:{
	clearContext: false // leave Jasmine Spec Runner output visible in browser
  },
  coverageIstanbulReporter: {
	reports: [ 'html', 'lcovonly' ],
	fixWebpackSourcePaths: true
  },
  reporters: ['progress', 'kjhtml'],
  port: 9876,
  colors: true,
  logLevel: config.LOG_INFO,
  autoWatch: true,
  browsers: ['Chrome'],
  singleRun: false
});

};`

I have my sample test.spec.js file in my root. I can now run the test, but i get the error that element is not defined.

This is the output of my tests
3 12 2020 22:23:14.381:WARN [karma]: No captured browser, open http://localhost:9876/
03 12 2020 22:23:14.417:INFO [karma-server]: Karma v5.2.3 server started at http://localhost:9876/
03 12 2020 22:23:14.418:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
03 12 2020 22:23:14.425:INFO [launcher]: Starting browser Chrome
03 12 2020 22:23:18.293:INFO [Chrome 87.0.4280.88 (Linux x86_64)]: Connected on socket DzhWJtbWYBQy5dtfAAAA with id 83672388
Chrome 87.0.4280.88 (Linux x86_64) test Test 0 FAILED
ReferenceError: element is not defined
at UserContext. (test.spec.js:12:21)
at
Chrome 87.0.4280.88 (Linux x86_64): Executed 1 of 2 (1 FAILED) (0 secs / 0.007 secs)
Chrome 87.0.4280.88 (Linux x86_64) test Test 0 FAILED
ReferenceError: element is not defined
at UserContext. (test.spec.js:12:21)
Chrome 87.0.4280.88 (Linux x86_64) test Test 1 FAILED
ReferenceError: element is not defined
at UserContext. (test.spec.js:16:22)
at
Chrome 87.0.4280.88 (Linux x86_64): Executed 2 of 2 (2 FAILED) (0 secs / 0.008 secs)
Chrome 87.0.4280.88 (Linux x86_64) test Test 1 FAILED
ReferenceError: element is not defined
at UserContext. (test.spec.js:16:22)
Chrome 87.0.4280.88 (Linux x86_64): Executed 2 of 2 (2 FAILED) (1.709 secs / 0.008 secs)
TOTAL: 2 FAILED, 0 SUCCESS
TOTAL: 2 FAILED, 0 SUCCESS

This is my test.spec.js
`
describe('test' , function () {

it('Test 0', function () {
    var title = element(by.control( { controlType : "sap.m.Title", id : /title$/ }));
    expect(title.asControl().getProperty("text")).toBe("myUI5App");
});
it('Test 1', function () {
    var button = element(by.control( { id : /idAppControl--idAppControl$/ })).element(by.control( { controlType : "sap.m.Page" })).element(by.control( { controlType : "sap.m.Button" }));
    button.click();
});

});
`

@maximnaidenov
Copy link
Contributor

Hi Jacob,
So far we did not invest time to implement code coverage in uiveri5 mainly due to lack of interest. But as you have implemented this, I will glad to have a look and possibly merge and/or help you by reviewing the code and advertising it as "officially supported plugin". Event further, we can plan and implement some hooks that maybe you need.
As for karma. Karma is a test launcher - it opens the browser and executes the test code in the browser context. In contrast uiveri5 is an e2e testing tool - it opens the browser, loads the app from real system and interacts with it.
And so the question is - what would be the value to execute those same tests in one more browser as they will control a second browser that will load the app ?
As for the error, it means that the "element API" is missing and this is obvious as it is a nodejs module we reuse from protractor.

@tsaleksandrova tsaleksandrova added the question Further information is requested label Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants