MountOps

com.raquo.domtestutils.MountOps
trait MountOps

Utilities for mounting / unmounting a single DOM node and running assertions on it. This functionality can be used with DOM nodes created by any means, you don't need to use Scala DOM Builder. This trait is (almost) agnostic of the testing frameworks. We have an adapter for ScalaTest, see MountSpec.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Abstract methods

def doAssert(condition: Boolean, message: String)(implicit prettifier: Prettifier, pos: Position): Unit

If condition is false, fail the test with a given message This method exists for compatibility with different test frameworks.

If condition is false, fail the test with a given message This method exists for compatibility with different test frameworks.

Attributes

def doFail(message: String)(implicit pos: Position): Nothing

Fail the test with a given message This method exists for compatibility with different test frameworks.

Fail the test with a given message This method exists for compatibility with different test frameworks.

Attributes

Concrete methods

def assertEmptyContainer(clue: String)(implicit prettifier: Prettifier, pos: Position): Unit
def assertRootNodeMounted(clue: String)(implicit prettifier: Prettifier, pos: Position): Unit
def clearDOM(clue: String)(implicit prettifier: Prettifier, pos: Position): Unit

Remove all traces of previous tests from the DOM: Unmount the root node and remove the container from the DOM

Remove all traces of previous tests from the DOM: Unmount the root node and remove the container from the DOM

Attributes

def createContainer(): Element
def expectNode(expectedNode: ExpectedNode)(implicit pos: Position): Unit

Check that the root node matches the provided description. Call doFail with an error message if the test fails.

Check that the root node matches the provided description. Call doFail with an error message if the test fails.

Attributes

def expectNode(actualNode: Node, expectedNode: ExpectedNode, clue: String)(implicit pos: Position): Unit

Check that a given node matches the provided description. Call doFail with an error message if the test fails.

Check that a given node matches the provided description. Call doFail with an error message if the test fails.

Attributes

def mount(node: Node)(implicit prettifier: Prettifier, pos: Position): Unit

Inject the root node into the DOM – with default clue Note: defaultMountedElementClue should not be made a default value on the above mount method because that prevents users from defining their own mount methods that accept default arguments ("multiple overloaded alternatives of method mount define default arguments") error

Inject the root node into the DOM – with default clue Note: defaultMountedElementClue should not be made a default value on the above mount method because that prevents users from defining their own mount methods that accept default arguments ("multiple overloaded alternatives of method mount define default arguments") error

Attributes

def mount(node: Node, clue: String)(implicit prettifier: Prettifier, pos: Position): Unit

Inject the root node into the DOM

Inject the root node into the DOM

Attributes

def mount(clue: String, node: Node)(implicit prettifier: Prettifier, pos: Position): Unit

Inject the root node into the DOM – alternative argument order for convenience

Inject the root node into the DOM – alternative argument order for convenience

Attributes

def resetDOM(clue: String)(implicit prettifier: Prettifier, pos: Position): Unit

Clear the DOM and create a new container. This should be called before each test.

Clear the DOM and create a new container. This should be called before each test.

Attributes

def rootNode: Node

Root node is the node that we test in expectNode. It is the only child of the containerNode element

Root node is the node that we test in expectNode. It is the only child of the containerNode element

Attributes

def unmount(clue: String)(implicit prettifier: Prettifier, pos: Position): Unit

Remove root node from the DOM

Remove root node from the DOM

Attributes

Concrete fields

var containerNode: Element

Container element that will hold the root node as a child. Container is mounted as a child of element

Container element that will hold the root node as a child. Container is mounted as a child of element

Attributes

var mountedElementClue: String

Prefix to add to error messages – useful to differentiate between different mount() calls within one test

Prefix to add to error messages – useful to differentiate between different mount() calls within one test

Attributes