Tag: 茉莉花

如何操作Jasmine JS在Webdriver的“文本”validation?

我已经尝试了很多代码,但没有通过testing。 通常,当试图读取此validation时,testing失败,或者收到“false”而不是“true”。 所有的脚本如下: describe('LiveSite Portal – Client share a document ', function() { it('LiveSite – Home Page', function() { liveSiteHome(); }); it('LiveSite Portal – Client share a document – Load new document', function() { element(by.xpath("//div[@class='actions-row']//a[.='Share Document']")).click(); browser.sleep(2000); expect (element(by.xpath("//div[@class='upload-section']/div[1]/div[2]/div")).isPresent()).toBe(true); captureScreen("documentForm"); browser.sleep(2000); element(by.css("input.file-input.upload-file-input")).sendKeys("C:\\automation\\myDocument.docx"); browser.sleep(3000); var reviewElement = element(by.bind('selectedFiles[0].name')); // expect (reviewElement.getText('myDocument.docx').isPresent()).toBe(true); expect(reviewElement.getText()).toEqual("myDocument.docx"); captureScreen("documentLoaded"); browser.sleep(2000); element(by.xpath("//div[@class='upload-section']/div[2]/div[2]/textarea")).sendKeys("Hi This […]

量angular器:在上传过程中检查存在的元素

我正在使用量angular器来自动化AngularJS应用程序。 有一种情况是我需要使用浏览button上传图片,并在上传过程中检查进度条是否存在。 我正在使用下面的代码来实现相同的: element(locator).sendKeys(pathOfTheImage); expect(element(locatorOfProgressBar).isPresent()).toBeTruthy(); 这里的问题是 – 尽pipe进度条存在,断言总是失败,因为element(locator).sendKeys(pathOfTheImage); 命令仍在进行中,并且没有返回任何内容来继续执行下一个命令,即断言点。 我曾尝试使用closures同步没有成功: browser.ignoreSynchronization = true; 任何解决这个问题? 如何在不等待sendKeys命令成功的情况下继续执行下一个命令?

在IE量angular器Asyc错误

我目前正在尝试testing下面的代码片段: <footer class="footer"> <div class="container"> <div class="row"> <form subscribe-directive="" ng-controller="SubscribeController" class="form col-xs-12 col-sm-8 col-md-6 col-lg-4 ng-scope ng-dirty ng-valid ng-valid-email"> <h3 class="footer__title text-uppercase margin-bottom-25">Sign up!</h3> <div class="row"> <div class="col-sm-8 col-xs-7"> <input type="email" class="form-control ng-touched ng-dirty ng-valid ng-valid-email" ng-disabled="working || subscription.done" placeholder="Email Address" ng-model="subscription.email"> </div> <div class="col-sm-4 col-xs-5"> <button ng-click="submit(subscription.email)" ng-disabled="working || !subscription.email || subscription.done" ng-class="{'working': working}" […]

NodeJS,Angular Seed,Gulp,Jasmine,Karma问题

build立一个angular种子,我有一切工作,我甚至可以启动茉莉花浏览器,但由于某种原因,我的规范不工作,所以我添加了一个karma.conf文件,它似乎打破了茉莉花浏览器。 我是新来的使用茉莉花,所以我很茫然,有很多关于如何做到最好的意见,但无论我尝试我似乎无法得到它的工作,我已经在这里添加回购链接为代码。 希望有人能够看到我做错了什么。 这个种子需要NodeJS 下载git,把它放在一个文件夹中,进入根目录下的config文件夹,运行npm install然后运行gulp,它会自动在控制台的浏览器中启动,你会看到这个错误 [14:52:17] 'jasmineWeb' errored after 2.27 ms [14:52:17] TypeError: object is not a function at Gulp.<anonymous> (/webdev/E20/config/gulpfile.js:137:11) at module.exports (/webdev/E20/config/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7) at Gulp.Orchestrator._runTask (/webdev/E20/config/node_modules/gulp/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/webdev/E20/config/node_modules/gulp/node_modules/orchestrator/index.js:214:10) at /webdev/E20/config/node_modules/gulp/node_modules/orchestrator/index.js:279:18 at finish (/webdev/E20/config/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8) at module.exports (/webdev/E20/config/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:60:3) at Gulp.Orchestrator._runTask (/webdev/E20/config/node_modules/gulp/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/webdev/E20/config/node_modules/gulp/node_modules/orchestrator/index.js:214:10) at /webdev/E20/config/node_modules/gulp/node_modules/orchestrator/index.js:279:18 这是我用来发射茉莉花的任务 gulp.task('jasmineWeb', function() { var filesForTest = ['../src/**/*.js', […]

如何对量angular器中的不同规格文件进行单独报告?

我们如何为量angular器中的不同规格文件制作单独的报告? multiCapabilities: [{ 'browserName': 'chrome' }, { 'browserName': 'firefox' } { 'browserName': 'internet explorer' }], framework: 'jasmine', specs: ['TC_2.js','TC_3.js'], 目前,我的代码会在第一次迭代时生成“chrome”执行的HTML报告。当它下一次迭代时,它会生成“FF”的报告。第三次迭代会生成“IE”报告。但是最后我得到最后一次迭代(即第三次)Internet Explorer的HTML报告在基地location.Because这最后一次迭代取代以前的迭代报告。 有没有办法得到所有3个报告?(即Chrome,FF和IE报告) 量angular器-html-截图记者是我正在使用的报告。 Following is my code: onPrepare: function() { beforeEach(function() { browser.driver.manage().window().setSize(1280, 1024); }); jasmine.getEnv().addReporter(new HtmlReporter({ baseDirectory: 'D:/Manoj/TestReport3/', docTitle: 'Test Case Execution Details', docName: 'BYTestReport.html', //Meta builder metaDataBuilder: function(spec, descriptions, results, capabilities){ var metaData […]

如何正确包含jasmine-nodetesting运行器的源文件

我正在使用jasmine spec库以及jasmine-node runner for node.js. 运行testing(cli中的命令)的正确方法是什么,它们都包含源文件和spec文件? 我有一个lib目录,包含我想包含的源代码和包含testing的unit.spec.js 当我做到以下,我得到一个错误: Tomasz.Ducin@WAWLT548 MINGW64 ~/Development/json-schema-faker/json-schema-faker (master) $ ./node_modules/.bin/jasmine-node lib unit.spec.js –noStackTrace –captureExceptions F. Failures: 1) A suite contains spec with an expectation Message: ReferenceError: booleanGenerator is not defined Finished in 0.007 seconds 2 Tests, 1 Failures, 0 Skipped booleanGenerator在lib目录中定义 – 但不知何故它不会被加载…不知道为什么。 CommonJS的function是否正确? 在茉莉花运行期间,我通过cli传递的path是分开的吗?

蓝鸟,茉莉花和asynchronousfunction未处理的拒绝错误

考虑以下(人为的)例子: import Promise from 'bluebird'; const resolvedPromise = () => { return Promise.resolve('Test'); }; const asyncFunc = async (asyncResource) => { await resolvedPromise(); await asyncResource.fetchItem(); }; describe('async/await', () => { it('should throw an error', (done) => { const mockAsyncResource = jasmine.createSpyObj('mockAsyncResource', ['fetchItem']); const mockError = Promise.reject(new Error('HTTP 401 – Access Denied')); mockAsyncResource.fetchItem.and.returnValue(mockError); return asyncFunc(mockAsyncResource).catch(err => […]

节点茉莉 – 如何unit testing函数涉及redis调用?

我刚刚开始玩茉莉花,我还在挣扎/嘲笑事情,例如,我有一个function module.exports = (() => { …. function getUserInfo(id) { return new Promise((resolve, reject) => { redis.getAsync(id).then(result => { resolve(result) }) }) } return { getUserInfo: getUserInfo } })() 然后我开始写Jasmine规范 describe('Test user helper', () => { let userInfo beforeEach(done => { userHelper.getUserInfo('userid123') .then(info => { userInfo = info done() }) }) it('return user info if […]

我如何使用服务器端打字稿项目的茉莉花?

我有一个项目,包含我的应用程序的服务器和客户端,这是每个使用webpack构build的模块。 我用茉莉花噶来testing我的客户端(使用Angular),我想用Jasmine来testing服务器,这也是打字稿。 不幸的是,我可以在网上find的唯一指南是使用jasmine-node(过去几年没有改动)而不是jasmine-npm。 任何人都可以build议一种方法,我可以使用茉莉花或替代品,在我的项目中进行testing? 我试过编写一个jasmine.json文件,或者用init cli命令编辑一个由jasmine生成的文件,但是这似乎不适用于typescript文件。 目前,我的项目结构如下: ├── client │ ├── karma.conf.js │ ├── protractor.conf.js │ ├── src │ ├── tsconfig.json │ └── webpack.config.js ├── server │ ├── src │ ├── tsconfig.json │ └── webpack.config.js └── node_modules

使用茉莉节点来监视全局function

我正在使用jasmine-node对javascript代码进行unit testing。 我有一些全球性的function,我想间谍,并允许通话,但尽pipe如此,原来的实施。 以下面的代码为例。 由于我无法解释的原因,我看到一个错误“globalFunction()方法不存在”。 有人可以告诉我,为什么茉莉花不能find这种globalFunction方法,我明白在全球范围内。 我感谢帮助 var globalFunction = function() { console.log('globalFunction'); }; describe("A Global Function", function() { jasmine.getEnv().addReporter(new jasmine.ConsoleReporter(console.log)); it("may be spied upon", function() { spyOn(global,'globalFunction').andCallThrough(); globalFunction(); expect(globalFunction).toHaveBeenCalled(); }); }); 这是茉莉花节点的输出 $ jasmine-node –verbose test.spec.js Runner Started. A Global Function : may be spied upon … Failed. A Global Function: 0 of 1 […]