https://testautomationu.applitools.com/cypress-with-typescript/chapter1.html
install type script Globerly
To view all different commands and flages
> tsc
it will convert TS file to JS
Cypress Auto-completion use following
but when using type script by adding default type script config file
references will help auto load
tsconfig.ts
custom commands on Type script and add header description
Add example
function is not use anymore/ obsalete
@deprecated
When having error on XPath with type script
1 add this in your
tsconfig.json file."cypress-xpath"
2 import "cypress-xpath" to command.ts file
Set specific value without using constent values
Create file helper\Typing\Placeholders.ts
create method using above mention types
when use it,only able to type given values
Change class to models
https://stackoverflow.com/questions/32805559/typescript-es6-import-module-file-is-not-a-module-error
// test.js - exporting es6
export module App {
export class SomeClass {
getName(): string {
return 'name';
}
}
export class OtherClass {
getName(): string {
return 'name';
}
}
}And now we can import it with these thre ways:
import * as app1 from "./test";
import app2 = require("./test");
import {App} from "./test";And we can consume imported stuff like this:
var a1: app1.App.SomeClass = new app1.App.SomeClass();
var a2: app1.App.OtherClass = new app1.App.OtherClass();
var b1: app2.App.SomeClass = new app2.App.SomeClass();
var b2: app2.App.OtherClass = new app2.App.OtherClass();
var c1: App.SomeClass = new App.SomeClass();
var c2: App.OtherClass = new App.OtherClass();and call the method to see it in action:
console.log(a1.getName())
console.log(a2.getName())
console.log(b1.getName())
console.log(b2.getName())
console.log(c1.getName())
console.log(c2.getName())change json imports to
old (it will not read data inside)
New