TwirlSuite

io.github.frikit.twirlspec.TwirlSuite
trait TwirlSuite extends FunSuite, TwirlSpecDsl, I18nChecks

twirl-spec for MUnit: what TwirlSpec gives a ScalaTest spec, for an MUnit suite. An application shared across the JVM, inject[View], languages, the expectation DSL, assertions over the same matchers, and the page catalogue as a test for each check:

class NameViewSuite extends TwirlSuite with HmrcServiceChecks {
 private val view = inject[NameView]
 private val form = Form(single("value" -> text))

 cataloguePage(formPage("NameView", form)(view(_))) {
   test("NameView asks for the name") {
     assertDisplays(renderPage(view(form)), heading("name.heading"))
   }
 }
}

Its rules are those its rule traits give, as in a ScalaTest spec, and its failures are MUnit's, with the same messages. ScalaTest stays on the class path, as the rules and matchers are built on it, but nothing here runs it.

Attributes

Source
TwirlSuite.scala
Graph
Supertypes
trait I18nChecks
trait TwirlSpecDsl
class FunSuite
trait BaseFunSuite
trait EventuallyTransforms
trait ValueTransforms
trait SuiteTransforms
trait TestTransforms
trait TestOptionsConversions
trait FunFixtures
trait Assertions
trait CompileErrorMacro
class Suite
trait PlatformSuite
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited classlikes

class FunFixture[T]

Attributes

Inherited from:
FunFixtures
Source
FunFixtures.scala
Supertypes
class Object
trait Matchable
class Any
object FunFixture

Attributes

Inherited from:
FunFixtures
Source
FunFixtures.scala
Supertypes
class Object
trait Matchable
class Any
final class SuiteTransform(val name: String, fn: (List[Test]) => List[Test]) extends (List[Test]) => List[Test]

Attributes

Inherited from:
SuiteTransforms
Source
SuiteTransforms.scala
Supertypes
trait (List[Test]) => List[Test]
class Object
trait Matchable
class Any
final class TestTransform(val name: String, fn: Test => Test) extends Test => Test

Attributes

Inherited from:
TestTransforms
Source
TestTransforms.scala
Supertypes
trait Test => Test
class Object
trait Matchable
class Any
final class ValueTransform(val name: String, fn: PartialFunction[Any, Future[Any]]) extends Any => Option[Future[Any]]

Attributes

Inherited from:
ValueTransforms
Source
ValueTransforms.scala
Supertypes
trait Any => Option[Future[Any]]
class Object
trait Matchable
class Any

Inherited types

final type AfterEach = AfterEach

Attributes

Inherited from:
Suite
Source
Suite.scala
final type BeforeEach = BeforeEach

Attributes

Inherited from:
Suite
Source
Suite.scala
final type Fixture[T] = Fixture[T]

Attributes

Inherited from:
Suite
Source
Suite.scala
final type Test = Test

Attributes

Inherited from:
Suite
Source
Suite.scala
final type TestValue = Future[Any]

The value produced by test bodies.

The value produced by test bodies.

Attributes

Inherited from:
Suite
Source
Suite.scala

Value members

Concrete methods

override def afterAll(): Unit

Runs once after all test cases and after all suite-local fixtures have been tear down.

Runs once after all test cases and after all suite-local fixtures have been tear down.

Attributes

Definition Classes
Suite
Source
TwirlSuite.scala
def applicationConfig: Map[String, Any]

Extra configuration for this suite's application.

Extra configuration for this suite's application.

Attributes

Source
TwirlSuite.scala
def assertDisplays(page: Page, expectations: Expectation*)(using loc: Location): Unit

The page shows all of this, and holds to every rule the suite runs.

The page shows all of this, and holds to every rule the suite runs.

Attributes

Source
TwirlSuite.scala
def assertMatches[A](value: A, matcher: Matcher[A])(using loc: Location): Unit

Any of this library's matchers as an MUnit assertion, failing with the matcher's own message: assertMatches(page, assertEverything).

Any of this library's matchers as an MUnit assertion, failing with the matcher's own message: assertMatches(page, assertEverything).

Attributes

Source
TwirlSuite.scala
def assertMeetsStandards(page: Page)(using loc: Location): Unit

The page holds to every rule the suite runs.

The page holds to every rule the suite runs.

Attributes

Source
TwirlSuite.scala
def assertTranslatesConsistently(pages: Seq[Page])(using loc: Location): Unit

The pages, one per language, say the same thing.

The pages, one per language, say the same thing.

Attributes

Source
TwirlSuite.scala
override def beforeAll(): Unit

Each run starts without the coverage and exclusion records of the last, and drops them once it has finished, as SuiteLifecycle does a ScalaTest spec's; the catalogue's pages render again. A suite that overrides beforeAll or afterAll calls super, as with ScalaTest's BeforeAndAfterAll, or a second run of it in the same JVM reads the records and pages of the first.

Each run starts without the coverage and exclusion records of the last, and drops them once it has finished, as SuiteLifecycle does a ScalaTest spec's; the catalogue's pages render again. A suite that overrides beforeAll or afterAll calls super, as with ScalaTest's BeforeAndAfterAll, or a second run of it in the same JVM reads the records and pages of the first.

Attributes

Definition Classes
Suite
Source
TwirlSuite.scala
def catalogue(pages: PageCase*): Unit

A test for each of each page's checks, as the ScalaTest catalogue writes them: "NameView must meet one-h1 in cy: ...", tagged by kind, language and rule.

A test for each of each page's checks, as the ScalaTest catalogue writes them: "NameView must meet one-h1 in cy: ...", tagged by kind, language and rule.

Attributes

Source
TwirlSuite.scala
def cataloguePage(page: PageCase)(tests: => Unit): Unit

A page's checks, then the suite's own tests of it.

A page's checks, then the suite's own tests of it.

Attributes

Source
TwirlSuite.scala
def currentLang: Lang

The language the current block runs in: English unless inside inLanguage.

The language the current block runs in: English unless inside inLanguage.

Attributes

Source
TwirlSuite.scala
def formPage[A](label: String, form: => Form[A], submissions: (String, Map[String, String])*)(view: (Form[A]) => Html): PageCase

A page with a form, blank and with the errors of its submissions, as PageCases.formPage makes it.

A page with a form, blank and with the errors of its submissions, as PageCases.formPage makes it.

Attributes

Source
TwirlSuite.scala
def inEachLanguage(block: Lang => Unit): Unit

Run the same block once per configured language.

Run the same block once per configured language.

Attributes

Source
TwirlSuite.scala
def inLanguage[A](lang: Lang)(block: => A): A

Run a block in a language the application is configured for.

Run a block in a language the application is configured for.

Attributes

Source
TwirlSuite.scala
def inject[A](using tag: ClassTag[A]): A

An instance from the application's injector.

An instance from the application's injector.

Attributes

Source
TwirlSuite.scala
def languages: Seq[Lang]

Every language the application is configured for, English first.

Every language the application is configured for, English first.

Attributes

Source
TwirlSuite.scala
def renderInEachLanguage(html: => Html): Seq[Page]

Render the same view in every configured language.

Render the same view in every configured language.

Attributes

Source
TwirlSuite.scala
def renderPage(html: => Html): Page

Render a view in the current language.

Render a view in the current language.

Attributes

Source
TwirlSuite.scala
def staticPage(label: String)(view: => Html): PageCase

A page with one state, as PageCases.staticPage makes it.

A page with one state, as PageCases.staticPage makes it.

Attributes

Source
TwirlSuite.scala
override protected def templateInstance(template: Class[_]): AnyRef

A template with injected dependencies, from the application, for the entry-point checks, as TwirlSpec gives it.

A template with injected dependencies, from the application, for the entry-point checks, as TwirlSpec gives it.

Attributes

Definition Classes
Source
TwirlSuite.scala

Inherited methods

def afterEach(context: AfterEach): Unit

Runs after each individual test case.

Runs after each individual test case.

Attributes

Inherited from:
Suite
Source
Suite.scala
protected def alertHook(message: String): Unit

Where a passing check's warnings go. Standard output here, because a spec base on this trait may have no ScalaTest reporter to hand, and a warning nobody sees is no warning. TwirlSpec routes them to ScalaTest's alert, and a spec base with Alerting can do the same in one line:

Where a passing check's warnings go. Standard output here, because a spec base on this trait may have no ScalaTest reporter to hand, and a warning nobody sees is no warning. TwirlSpec routes them to ScalaTest's alert, and a spec base with Alerting can do the same in one line:

override protected def alertHook(message: String): Unit = alert(message)

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def appearsBefore(first: String, second: String): Expectation

One selector's first match comes before another's in document order.

One selector's first match comes before another's in document order.

Reading order is not a detail: an error summary announced after the form it describes is announced too late to be useful.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def assert(cond: => Boolean, clue: => Any = ...)(implicit loc: Location): Unit

Asserts that the given condition is true.

Asserts that the given condition is true.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def assertEquals[A, B](obtained: A, expected: B, clue: => Any = ...)(implicit loc: Location, compare: Compare[A, B], diffOptions: DiffOptions): Unit

Asserts that two elements are equal according to the Compare[A, B] type-class.

Asserts that two elements are equal according to the Compare[A, B] type-class.

By default, uses == to compare values.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def assertEqualsDouble(obtained: Double, expected: Double, delta: Double, clue: => Any = ...)(implicit loc: Location): Unit

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Asserts that two doubles are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Double.NaN, Double.NaN, *) passes.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def assertEqualsFloat(obtained: Float, expected: Float, delta: Float, clue: => Any = ...)(implicit loc: Location): Unit

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Asserts that two floats are equal to within a positive delta. If the expected value is infinity then the delta value is ignored. NaNs are considered equal: assertEquals(Float.NaN, Float.NaN, *) passes.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def assertMatches[A](value: A, clue: => String = ...)(predicate: PartialFunction[A, Boolean])(implicit loc: Location): Unit

Asserts that the given partial function is defined for the given value and that applying the partial function to the value returns true.

Asserts that the given partial function is defined for the given value and that applying the partial function to the value returns true.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def assertNoDiff(obtained: String, expected: String, clue: => Any = ...)(implicit loc: Location, diffOptions: DiffOptions): Unit

Asserts that two strings are equal, ignoring non-visible differences such as whitespace. Useful for comparing multiline strings.

Asserts that two strings are equal, ignoring non-visible differences such as whitespace. Useful for comparing multiline strings.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def assertNotEquals[A, B](obtained: A, expected: B, clue: => Any = ...)(implicit loc: Location, compare: Compare[A, B]): Unit

Asserts that two elements are not equal according to the Compare[A, B] type-class.

Asserts that two elements are not equal according to the Compare[A, B] type-class.

By default, uses == to compare values.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def assume(cond: Boolean, clue: => Any = ...)(implicit loc: Location): Unit

Aborts the test if the given condition is false. In contrast with assert, a failed assumption does not fail the test, but rather marks it as skipped.

Aborts the test if the given condition is false. In contrast with assert, a failed assumption does not fail the test, but rather marks it as skipped.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def basedOn(lang: Lang): Matcher[Seq[Page]]

Measure the other languages against this one rather than against the first page given.

Measure the other languages against this one rather than against the first page given.

Attributes

Inherited from:
I18nChecks
Source
I18nChecks.scala
def beforeEach(context: BeforeEach): Unit

Runs before each individual test case. An error in this method aborts the test case.

Runs before each individual test case. An error in this method aborts the test case.

Attributes

Inherited from:
Suite
Source
Suite.scala
def bullets(keys: String*): Expectation

The bullet list contains exactly these items, in order.

The bullet list contains exactly these items, in order.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def button(id: String, key: String): Expectation

The button with this id says this.

The button with this id says this.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def caption(expected: Expected): Expectation

The caption against any expected value.

The caption against any expected value.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def caption(key: String, args: Any*): Expectation

The caption rendered above (or inside) the h1.

The caption rendered above (or inside) the h1.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def captionText(literal: String): Expectation

The caption, given as the exact words rather than a message key.

The caption, given as the exact words rather than a message key.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def checkPage(page: Page, expectations: Seq[Expectation]): CheckReport

Assert against a page directly, outside a matcher.

Assert against a page directly, outside a matcher.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def checkboxGroup(name: String = ...): ChoiceGroupExpectation

The checkboxes sharing this name, value by default.

The checkboxes sharing this name, value by default.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def clue[T](c: Clue[T]): T

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def clues(clue: Clue[_]*): Clues

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def columnHeaders(keys: String*): Expectation

The column headers of the one table on the page, or in within, in order: what tableHeaders reads, less the header each row has of its own.

The column headers of the one table on the page, or in within, in order: what tableHeaders reads, less the header each row has of its own.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
transparent inline def compileErrors(inline code: String): String

Return compilation errors as String.

Return compilation errors as String.

Note: for reproducible results set -pagewidth scalac option to a fixed value, eg 80.

Value parameters

code

scala code that should not compile

Attributes

Returns

formatted errors

Inherited from:
CompileErrorMacro
Source
MacroCompat.scala
def content(key: String, args: Any*): Expectation

The resolved message appears somewhere in the page's visible text.

The resolved message appears somewhere in the page's visible text.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def contentText(literal: String): Expectation

Somewhere in the page body, given as the exact words rather than a message key.

Somewhere in the page body, given as the exact words rather than a message key.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def cssSelector(selector: String): Expectation

At least one element matches this selector. The plural form, where several matches are legitimate.

At least one element matches this selector. The plural form, where several matches are legitimate.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def dateInput(name: String = ...): DateInputExpectation

A GOV.UK date input, three fields under one legend, named value by default.

A GOV.UK date input, three fields under one legend, named value by default.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def describedAs(nameOrId: String, key: String, args: Any*): Expectation

What an assistive technology reads after the control's name.

What an assistive technology reads after the control's name.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def detailsSummary(key: String, args: Any*): Expectation

The visible summary of a collapsed details block.

The visible summary of a collapsed details block.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def disabled(nameOrId: String): Expectation

The control is disabled, on itself or through an enclosing fieldset.

The control is disabled, on itself or through an enclosing fieldset.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def display(expectations: Expectation*): Matcher[Page]

The page shows all of this, and holds to every rule standardsRules resolves to: none in the core, and each check trait's own once mixed in.

The page shows all of this, and holds to every rule standardsRules resolves to: none in the core, and each check trait's own once mixed in.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def displayOnly(expectations: Expectation*): Matcher[Page]

As display, but without the standards — for the rare page that has to break a rule, or while a legacy view is being brought up to standard.

As display, but without the standards — for the rare page that has to break a rule, or while a legacy view is being brought up to standard.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def element(id: String): Expectation

An element with this id exists.

An element with this id exists.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def elementCount(selector: String, expected: Int): Expectation

Exactly this many elements match.

Exactly this many elements match.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def elementHasClass(id: String, className: String): Expectation

The element with this id carries this class.

The element with this id carries this class.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def elementWithText(id: String, key: String, args: Any*): Expectation

The element with this id says this.

The element with this id says this.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def enabled(nameOrId: String): Expectation

This control is not disabled.

This control is not disabled.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def errorSummary(entries: (String, String)*): Expectation

The error summary lists exactly these field -> message key entries, in order, and every entry links to an element that exists on the page.

The error summary lists exactly these field -> message key entries, in order, and every entry links to an element that exists on the page.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def errorSummaryContaining(field: String, key: String, args: Any*): Expectation

The error summary mentions this field, whatever else it lists.

The error summary mentions this field, whatever else it lists.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def errorSummaryTitle(key: String = ...): Expectation

The heading above the error summary.

The heading above the error summary.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def eventually[A](body: => A)(implicit options: EventuallyOptions, transform: EventuallyTransform[A]): A

Evaluates the effectful body until it succeeds or max retries are exhausted.

Evaluates the effectful body until it succeeds or max retries are exhausted.

Attributes

Inherited from:
EventuallyTransforms
Source
EventuallyTransforms.scala
def exactTitle(literal: String): Expectation

The browser title in full, including service name and " - GOV.UK".

The browser title in full, including service name and " - GOV.UK".

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala

Bundle expectations so a service can name its own house rules once.

Bundle expectations so a service can name its own house rules once.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def fail(message: String, clues: Clues = ...)(implicit loc: Location, diffOptions: DiffOptions): Nothing

Unconditionally fails this test with the given message and optional clues.

Unconditionally fails this test with the given message and optional clues.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def fail(message: String, cause: Throwable)(implicit loc: Location, diffOptions: DiffOptions): Nothing

Unconditionally fails this test with the given message and exception marked as the cause.

Unconditionally fails this test with the given message and exception marked as the cause.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def failComparison(message: String, obtained: Any, expected: Any, clues: Clues = ...)(implicit loc: Location, diffOptions: DiffOptions): Nothing

Unconditionally fails this test due to result of comparing two values.

Unconditionally fails this test due to result of comparing two values.

The only reason to use this method instead of fail() is if you want to allow comparing the two different values in the the IntelliJ GUI diff viewer.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def failOnWarnings: Boolean

Whether warnings fail the test.

Whether warnings fail the test.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def failSuite(message: String, clues: Clues = ...)(implicit loc: Location, diffOptions: DiffOptions): Nothing

Unconditionally fail this test case and cancel all the subsequent tests in this suite.

Unconditionally fail this test case and cancel all the subsequent tests in this suite.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def fieldError(field: String, key: String, args: Any*): Expectation

The inline error message rendered against a specific field.

The inline error message rendered against a specific field.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def fileUpload(name: String): Expectation

A file input with this name or id is present.

A file input with this name or id is present.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def formGetsFrom(url: String): Expectation

The form is a GET to this action.

The form is a GET to this action.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def formPostsTo(url: String): Expectation

The form posts (or gets) to a specific URL.

The form posts (or gets) to a specific URL.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def formValues(expected: (String, String)*): Expectation

Each name submits this value, as a browser would submit the form. For a name submitted more than once, such as a group of checkboxes, the value has to be among the ones it submits.

Each name submits this value, as a browser would submit the form. For a name submitted more than once, such as a group of checkboxes, the value has to be among the ones it submits.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def heading(expected: Expected): Expectation

The single = against any expected value, ignoring a caption rendered inside it.

The single = against any expected value, ignoring a caption rendered inside it.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def heading(key: String, args: Any*): Expectation

The single =.

The single =.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def headingAtLevel(level: Int, expected: Expected): Expectation

A heading at a given level says this.

A heading at a given level says this.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def headingText(literal: String): Expectation

The =, given as the exact words rather than a message key.

The =, given as the exact words rather than a message key.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def hiddenInput(name: String, value: String): Expectation

A hidden input with this name carries this value.

A hidden input with this name carries this value.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def insetText(key: String, args: Any*): Expectation

The text of an inset text block.

The text of an inset text block.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def intercept[T <: Throwable](body: => Any)(implicit T: ClassTag[T], loc: Location): T

Evalutes the given expression and asserts that an exception of type T is thrown.

Evalutes the given expression and asserts that an exception of type T is thrown.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def interceptMessage[T <: Throwable](expectedExceptionMessage: String)(body: => Any)(implicit T: ClassTag[T], loc: Location): T

Evalutes the given expression and asserts that an exception of type T with the expected message is thrown.

Evalutes the given expression and asserts that an exception of type T with the expected message is thrown.

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def invalid(nameOrId: String): Expectation

The control is marked invalid for an assistive technology.

The control is marked invalid for an assistive technology.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def isCI: Boolean

Attributes

Inherited from:
SuiteTransforms
Source
SuiteTransforms.scala
def linkText(literal: String): LinkExpectation

A link, given as the exact words rather than a message key.

A link, given as the exact words rather than a message key.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def linkWithId(id: String): LinkExpectation

A link found by id, whatever it says.

A link found by id, whatever it says.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def literal(exactWords: String): Expected

Text expectations take message keys by default; wrap a string in literal when you really do mean the exact words.

Text expectations take message keys by default; wrap a string in literal when you really do mean the exact words.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def matchOutlineSnapshot(file: Path): Matcher[Page]

The page's outline, as page.outline prints it, is the one saved in this file:

The page's outline, as page.outline prints it, is the one saved in this file:

render(view(form)) must matchOutlineSnapshot(Path.of("test/resources/outlines/name.txt"))

A file that is missing, or holds another outline, fails, with the page's outline or the lines that differ, and updateOutlineSnapshots writes it instead. Line endings and spaces at the ends of lines do not count. The outline's format changes only in a minor version, whose changelog says so. A snapshot asserts nothing for coverage: assertEverything still asks for what the page shows to be asserted.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def matching(regex: Regex): Expected

Match text against a regular expression rather than an exact string.

Match text against a regular expression rather than an exact string.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def meetStandards: Matcher[Page]

Whatever standardsRules resolves to, for a spec that has its own assertions already.

Whatever standardsRules resolves to, for a spec that has its own assertions already.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def meetStandardsExcept(ruleIds: Seq[String], because: String): Matcher[Page]

As meetStandardsExcept, with the reason for the exclusion, which a failure then reports alongside the ids:

As meetStandardsExcept, with the reason for the exclusion, which a failure then reports alongside the ids:

page must meetStandardsExcept(Seq("one-h1"), because = "legacy page, see JIRA-123")

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def meetStandardsExcept(ruleIds: String*): Matcher[Page]

The standards, minus the named rules. Prefer fixing the page: an exclusion here hides the rule on every page it is applied to.

The standards, minus the named rules. Prefer fixing the page: an exclusion here hides the rule on every page it is applied to.

Every id must name an active rule. A misspelt id, or one for a rule this spec does not run, would exclude nothing, so it fails the match instead. The excluded rules still run, silently, so unusedExclusions can tell an exclusion that is still needed from one that has outlived its reason.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def messageKey(key: String, args: Any*): Expected

A message key with its arguments, where an expectation takes any expected value: summaryList(messageKey("x.dob", name) -> "27 March 1993").

A message key with its arguments, where an expectation takes any expected value: summaryList(messageKey("x.dob", name) -> "27 March 1993").

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def messageText(key: String, args: Any*)(implicit messages: Messages): String

A message, resolved and normalised, ready to compare against page text.

A message, resolved and normalised, ready to compare against page text.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def munitAnsiColors: Boolean

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def munitAppendToFailureMessage(buildSuffix: Test => Option[String]): TestTransform

Optionally augment a failure with additional information.

Optionally augment a failure with additional information.

Failures that are not FailExceptionLike subclasses will be wrapped, if needed.

Attributes

Inherited from:
TestTransforms
Source
TestTransforms.scala
def munitCaptureClues[T](thunk: => T): (T, Clues)

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def munitExecutionContext: ExecutionContext

Attributes

Inherited from:
Suite
Source
Suite.scala

Attributes

Inherited from:
TestTransforms
Source
TestTransforms.scala
def munitFixtures: Seq[AnyFixture[_]]

Fixtures that can be reused for individual test cases or entire suites.

Fixtures that can be reused for individual test cases or entire suites.

Attributes

Inherited from:
Suite
Source
Suite.scala
def munitFlakyOK: Boolean

Attributes

Inherited from:
TestTransforms
Source
TestTransforms.scala

Attributes

Inherited from:
TestTransforms
Source
TestTransforms.scala

Attributes

Inherited from:
ValueTransforms
Source
ValueTransforms.scala
def munitIgnore: Boolean

Attributes

Inherited from:
SuiteTransforms
Source
SuiteTransforms.scala

Attributes

Inherited from:
SuiteTransforms
Source
SuiteTransforms.scala

Attributes

Inherited from:
SuiteTransforms
Source
SuiteTransforms.scala
def munitPrint(clue: => Any): String

Attributes

Inherited from:
Assertions
Source
Assertions.scala
final def munitSuiteTransform(tests: List[Test]): List[Test]

Attributes

Inherited from:
SuiteTransforms
Source
SuiteTransforms.scala

Attributes

Inherited from:
SuiteTransforms
Source
SuiteTransforms.scala
final def munitTestTransform(test: Test): Test

Attributes

Inherited from:
TestTransforms
Source
TestTransforms.scala

Attributes

Inherited from:
TestTransforms
Source
TestTransforms.scala
def munitTests(): Seq[Test]

The base class for all test suites

The base class for all test suites

Attributes

Inherited from:
BaseFunSuite
Source
FunSuite.scala
def munitTimeout: Duration

Attributes

Inherited from:
BaseFunSuite
Source
FunSuite.scala
final def munitValueTransform(testValue: => Any): Future[Any]

Attributes

Inherited from:
ValueTransforms
Source
ValueTransforms.scala

Attributes

Inherited from:
ValueTransforms
Source
ValueTransforms.scala
def noContent(key: String, args: Any*): Expectation

The resolved message appears nowhere in the page's visible text.

The resolved message appears nowhere in the page's visible text.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def noCssSelector(selector: String): Expectation

Nothing matches this selector.

Nothing matches this selector.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def noElement(id: String): Expectation

No element with this id exists.

No element with this id exists.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def normalised(raw: String): String

Page text has its quotes, spaces and soft hyphens normalised before comparison, and a raw messages(...) value has not — so page.text must include(messages("x")) fails on a curly apostrophe that looks identical. Normalise the expected side the same way.

Page text has its quotes, spaces and soft hyphens normalised before comparison, and a raw messages(...) value has not — so page.text must include(messages("x")) fails on a curly apostrophe that looks identical. Normalise the expected side the same way.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def notificationBanner(key: String, args: Any*): Expectation

The text of a notification banner.

The text of a notification banner.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def numberedItems(keys: String*): Expectation

The numbered list contains exactly these items, in order.

The numbered list contains exactly these items, in order.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def panelBody(key: String, args: Any*): Expectation

The body of a confirmation panel.

The body of a confirmation panel.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def panelTitle(key: String, args: Any*): Expectation

The title of a confirmation panel.

The title of a confirmation panel.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def paragraph(key: String, args: Any*): Expectation

The message appears inside a paragraph.

The message appears inside a paragraph.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def printer: Printer

Attributes

Inherited from:
Assertions
Source
Assertions.scala
def radioGroup(name: String = ...): ChoiceGroupExpectation

The radio buttons sharing this name, value by default as Play's form helpers name them.

The radio buttons sharing this name, value by default as Play's form helpers name them.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def render(html: Html, lang: Lang, messages: Messages): Page

Parse rendered HTML into a page for an explicit language and its messages, rather than the implicit ones.

Parse rendered HTML into a page for an explicit language and its messages, rather than the implicit ones.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def render(html: Html)(implicit messages: Messages): Page

Parse rendered HTML into a page that can be asked questions.

Parse rendered HTML into a page that can be asked questions.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def renderIn(lang: Lang)(html: Messages => Html)(implicit messagesApi: MessagesApi): Page

Render the same view in a given language, which must be one the application is configured for.

Render the same view in a given language, which must be one the application is configured for.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def reportWarnings: Boolean

Whether passing tests still surface their warnings in the test output.

Whether passing tests still surface their warnings in the test output.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def required(nameOrId: String): Expectation

This control is marked required.

This control is marked required.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def role(role: String): RoleExpectation

Find an element the way an assistive technology does: by role, then by the name it announces. Prefer this over an id or a class — if a control cannot be found by role and name, it cannot be found by a screen reader either.

Find an element the way an assistive technology does: by role, then by the name it announces. Prefer this over an id or a class — if a control cannot be found by role and name, it cannot be found by a screen reader either.

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala
def serviceName(key: String = ...): Expectation

The service or site name in the header.

The service or site name in the header.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala

The active rule set as one expectation, for asserting on the result.

The active rule set as one expectation, for asserting on the result.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def standardsRules: Seq[Rule]

Which rules run alongside every display(...). Empty here; rule modules add theirs via super.standardsRules.

Which rules run alongside every display(...). Empty here; rule modules add theirs via super.standardsRules.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def subheading(key: String, args: Any*): Expectation

An h2 with the given message key.

An h2 with the given message key.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def submitButton(key: String = ...): Expectation

The submit control says this, site.continue by default.

The submit control says this, site.continue by default.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def submitButtonText(literal: String): Expectation

The submit control says exactly these words.

The submit control says exactly these words.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def summaryList(rows: (String | Expected, String)*): Expectation

The summary list holds exactly these key -> value rows, in order. A key is a message key, or any expected value: messageKey("x.dob", name) for one that takes arguments, literal, matching or anyText.

The summary list holds exactly these key -> value rows, in order. A key is a message key, or any expected value: messageKey("x.dob", name) for one that takes arguments, literal, matching or anyText.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def summaryRow(key: String, args: Any*): SummaryRowExpectation

A row of a govukSummaryList, by its key.

A row of a govukSummaryList, by its key.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def tableHeaders(keys: String*): Expectation

The table header cells, in order.

The table header cells, in order.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def tableRow(cells: String*): Expectation

A row whose cells read exactly like this.

A row whose cells read exactly like this.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def test(options: TestOptions)(body: => Any)(implicit loc: Location): Unit

Attributes

Inherited from:
BaseFunSuite
Source
FunSuite.scala
def test(name: String)(body: => Any)(implicit loc: Location): Unit

Attributes

Inherited from:
BaseFunSuite
Source
FunSuite.scala
def textArea(name: String): TextInputExpectation

A textarea found by name or id, with the same builders as textInput.

A textarea found by name or id, with the same builders as textInput.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def textInput(name: String): TextInputExpectation

A text input found by name or id; chain the builders for its label, hint, value, autocomplete and type.

A text input found by name or id; chain the builders for its label, hint, value, autocomplete and type.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala
def title(expected: Expected): Expectation

The browser title against any expected value, ignoring the layout's suffix and an error prefix.

The browser title against any expected value, ignoring the layout's suffix and an error prefix.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def title(key: String, args: Any*): Expectation

The browser title, ignoring the " - Service name - GOV.UK" suffix the layout appends and the translated "Error:" prefix an error state adds.

The browser title, ignoring the " - Service name - GOV.UK" suffix the layout appends and the translated "Error:" prefix an error state adds.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def titleText(literal: String): Expectation

The browser title, given as the exact words rather than a message key.

The browser title, given as the exact words rather than a message key.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
def translateConsistently: Matcher[Seq[Page]]

Every language renders the same page as the base language, differing only in words.

Every language renders the same page as the base language, differing only in words.

Attributes

Inherited from:
I18nChecks
Source
I18nChecks.scala
def translateConsistentlyExcept(ruleIds: String*): Matcher[Seq[Page]]

As translateConsistently, without the named rules.

As translateConsistently, without the named rules.

Attributes

Inherited from:
I18nChecks
Source
I18nChecks.scala

What a page may legitimately keep the same between languages.

What a page may legitimately keep the same between languages.

Attributes

Inherited from:
I18nChecks
Source
I18nChecks.scala
def translationDifferences(pages: Seq[Page], base: Option[Lang] = ...): Seq[Violation]

The differences, for a spec that would rather report than fail.

The differences, for a spec that would rather report than fail.

Attributes

Inherited from:
I18nChecks
Source
I18nChecks.scala
def unusedExclusions: Seq[String]

The rules this spec has excluded with meetStandardsExcept that found nothing on any page they were excluded from, and so exclude nothing.

The rules this spec has excluded with meetStandardsExcept that found nothing on any page they were excluded from, and so exclude nothing.

Ask it in the spec's last test, once every exclusion has run:

"need every exclusion it makes" in { unusedExclusions mustBe empty }

It knows only the tests that have run, so a run of one test can report an exclusion that another test needs.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def updateOutlineSnapshots: Boolean

Whether matchOutlineSnapshot writes the file it is given, where the file is missing or holds another outline, rather than failing. On where the environment sets TWIRLSPEC_UPDATE_SNAPSHOTS=true, to write snapshots again locally after a page was changed on purpose. Never in CI, where it would pass whatever a page had become.

Whether matchOutlineSnapshot writes the file it is given, where the file is missing or holds another outline, rather than failing. On where the environment sets TWIRLSPEC_UPDATE_SNAPSHOTS=true, to write snapshots again locally after a page was changed on purpose. Never in CI, where it would pass whatever a page had become.

Attributes

Inherited from:
TwirlMatchers
Source
TwirlMatchers.scala
def warning(key: String, args: Any*): Expectation

The text of a GOV.UK warning callout.

The text of a GOV.UK warning callout.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala
def within(selector: String)(expectations: Expectation*): Expectation

These expectations, asked of one part of the page: the one element this selector matches, for a page with two tables, or a search form before the form under test.

These expectations, asked of one part of the page: the one element this selector matches, for a page with two tables, or a search form before the form under test.

within("#results")(columnHeaders("x.name", "x.born"), tableRow("Ada", "1815"))
within("form[action='/save']")(formPostsTo("/save"), submitButton())

What it matches has to be one element, or the expectation fails, as it does for anything naming one element. What an element says of another by id, such as for or aria-describedby, still reaches the whole page. So do the standards, and the page's title and language. What is asserted here counts for the page's coverage.

Attributes

Inherited from:
ContentExpectations
Source
ContentExpectations.scala

Concrete fields

lazy val app: Application

The application this suite renders with, shared across the JVM with every suite, of either kind, that uses the same applicationConfig.

The application this suite renders with, shared across the JVM with every suite, of either kind, that uses the same applicationConfig.

Attributes

Source
TwirlSuite.scala
val english: Lang

The English Lang, the base language.

The English Lang, the base language.

Attributes

Source
TwirlSuite.scala
lazy val messagesApiInstance: MessagesApi

The application's MessagesApi.

The application's MessagesApi.

Attributes

Source
TwirlSuite.scala

Inherited fields

For "there is a heading, its wording is asserted elsewhere".

For "there is a heading, its wording is asserted elsewhere".

Attributes

Inherited from:
TwirlSpecDsl
Source
TwirlSpecDsl.scala

GOV.UK requires the browser title of a page in an error state to be prefixed, so screen reader users hear that something went wrong before the page name.

GOV.UK requires the browser title of a page in an error state to be prefixed, so screen reader users hear that something went wrong before the page name.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala

A submit control is present, whatever it says.

A submit control is present, whatever it says.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala

A language switcher, however it is rendered.

A language switcher, however it is rendered.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala
val munitLines: Lines

Attributes

Inherited from:
Assertions
Source
Assertions.scala
final val munitTestsBuffer: ListBuffer[Test]

Attributes

Inherited from:
BaseFunSuite
Source
FunSuite.scala

No error summary and no inline error messages anywhere on the page.

No error summary and no inline error messages anywhere on the page.

Attributes

Inherited from:
FormExpectations
Source
FormExpectations.scala

The alpha or beta phase banner is present.

The alpha or beta phase banner is present.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala

The session-timeout dialog is wired up.

The session-timeout dialog is wired up.

Attributes

Inherited from:
FramingExpectations
Source
FramingExpectations.scala

Implicits

Implicits

implicit def messages: Messages

Messages for the current language, implicitly.

Messages for the current language, implicitly.

Attributes

Source
TwirlSuite.scala
implicit def messagesApi: MessagesApi

The application's MessagesApi, implicitly.

The application's MessagesApi, implicitly.

Attributes

Source
TwirlSuite.scala
implicit def request: Request[AnyContentAsEmpty.type]

A GET request for the current language, implicitly, signed with a CSRF token where Play's filters are on the class path, as TwirlSpec's is.

A GET request for the current language, implicitly, signed with a CSRF token where Play's filters are on the class path, as TwirlSpec's is.

Attributes

Source
TwirlSuite.scala

Inherited implicits

implicit def implicitContext: SuiteContext

Wraps non-implicit fields as implicit

Wraps non-implicit fields as implicit

Attributes

Inherited from:
BaseFunSuite
Source
FunSuite.scala
implicit def testOptionsFromString(name: String)(implicit loc: Location): TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Implicitly create a TestOptions given a test name. This allows writing test("name") { ... } even if test accepts a TestOptions

Attributes

Inherited from:
TestOptionsConversions
Source
TestOptions.scala