EasyTest has a built-in DOM
object that allows you to test HTML elements
in your tests (we use happy-dom
to create one).
For testing HTML elements, global objects such as window, document and corresponding global methods and interfaces are created.
To enable global DOM, you need to use parameter --dom
in the command line,
or set dom
to true
in the configuration file.
or
Also you can use DOM.setup()
method to set up the DOM object manually.
In each test, you can use the window
and document
objects to test the HTML elements.
EasyTest exports the DOM
object that contains methods and properties for working with the DOM.
css
- scope, contains methods to load CSS files.js
- scope, contains methods to load JavaScript.fromFile()
- loads CSS styles from file. This method creates a style tag with the content.
fromString()
- loads the CSS from string. This method creates a style tag with the content.
fromUrl()
- loads the CSS from URL. This method creates a link tag with the href attribute.
fromObject()
- create CSS from object.
Create tag style and put into textContent
contents of style.css
file.
Create tag style and put into textContent
string content
Create tag link with href to URL
Create tag style and put into textContent
object content
fromFile()
- loads JavaScript from a file.
fromString()
- loads JavaScript from a string.
fromUrl()
- loads JavaScript from a URL.
Create tag script and put into script.js file content
Create tag script and put into string content
Create tag script with src to URL
setup(options)
- sets up the DOM object.bye()
- removes the DOM object.html(str)
- Set Document HTML.eval()
- evaluates the JavaScript code.$()
- synonym for document.querySelector()
.$$()
- synonym for document.querySelectorAll()
.flush()
- removes all elements from the document.EasyTest automatically sets up the DOM object before each test. But you can set up the DOM object manually.
All setup options are optional.