Javascript 角度2-量角器测试:找不到名称';元素';和';名称';
惠 我已经创建了app.e2e-spec.ts文件来创建单元测试:Javascript 角度2-量角器测试:找不到名称';元素';和';名称';,javascript,angular,unit-testing,protractor,Javascript,Angular,Unit Testing,Protractor,惠 我已经创建了app.e2e-spec.ts文件来创建单元测试: import {} from 'jasmine'; import {} from 'protractor'; describe('Testing login button disable if empty input texts', function() { it('should username have null value', function() { var inputsLogin = element(by
import {} from 'jasmine';
import {} from 'protractor';
describe('Testing login button disable if empty input texts', function() {
it('should username have null value', function() {
var inputsLogin = element(by.name('username'));
expect<any>(inputsLogin.getAttribute('value')).toBe(null);
});
it('should password have null value', function() {
var inputsPassword = element(by.name('password'));
expect<any>(inputsPassword.getAttribute('value')).toBe(null);
});
it('should login button disable', function() {
var loginButton = element(by.id('button-confirm'));
expect<any>(loginButton.getAttribute('disabled')).toBe("true");
});
});
但我有时可以运行测试,因为Intellj为我创建了js
我的tsconfig.js:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"./node_modules/@types/"
]
},
"include": [
"src/**/*.ts",
"tests/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}您将导入语句留空
import {by, element} from 'protractor';
您将导入语句留空
import {by, element} from 'protractor';
谢谢,我很笨,我以为让import语句清空导入了整个模块,但它是*。那么为什么它适用于jasmine呢?可能在您的配置中,jasmine正在使用打字。打字不需要导入。谢谢,我很笨,我以为让import语句清空导入了整个模块,但它是*。那么为什么它适用于jasmine呢?可能在您的配置中,jasmine正在使用打字。打字不需要导入。