0
我創建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.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");
});
});
的單元測試工作,但問題是,當我運行tsc
命令,我得到這些錯誤:
tests/tests-e2e/app.e2e-specs.ts(10,27): error TS2304: Cannot find name 'element'.
tests/tests-e2e/app.e2e-specs.ts(10,35): error TS2304: Cannot find name'by'
tests/tests-e2e/app.e2e-specs.ts(15,30): error TS2304: Cannot find name'element'
...
但由於Intellj我
012創建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
}
}
謝謝我很笨我以爲讓導入語句空導入整個模塊,但它是*。那麼爲什麼它適用於茉莉花? – gigeos
可能在您的配置中,茉莉花正在使用類型。類型不需要導入。 –