question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

airspec: custom assertion

See original GitHub issue

It would be great if airspec support custom assertion feature as in other test frameworks.

One of my usecase of custom assertion is verifying equality of objects in JavaScript world on Scala.js. Unfortunately, == operator does not return true on a pair of JS objects whose contents are identical, unlike Scala objects (e.g. Seq(1) == Seq(1)). It is ofcourse possible to check content-equality when user define a predicate function something like this:

def contentEqual(a: js.Array[_], b: js.Array[_]): Boolean = {
  a.length == b.length && (a zip b).forall(_._1 == _._2)
}

test("js array") {
  val actual: js.Array[Int] = getA()
  assert(contentEqual(actual, Array(1, 2, 3)) 
}

But this is not helpful on test failure, because it is unclear which element is wrong. As an user, I expect helpful failure message like [4,5,6] is not equal to [1,2,3], which helps debugging.

This feature request may be related to

Power assertion for test failures (e.g., show the condition expression and data differences) #839

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xerialcommented, Feb 12, 2020

@exoego This feature is included in Airframe 20.2.0 along with Scala.js 1.0.0 support. Thanks!

0reactions
xerialcommented, Feb 1, 2020

Ok. #922 is a PR for this and we need to wait Scala.js 1.0.0 release to use js.Object.entries method https://github.com/scala-js/scala-js/pull/3869

Read more comments on GitHub >

github_iconTop Results From Across the Web

AirSpec: Testing Framework · Airframe - wvlet.github.io
This test syntax is useful for writing nested tests or customizing the design of DI for each test. Assertions in AirSpec. AirSpec supports...
Read more >
AirSpec: Writing Tests As Plain Functions In Scala - Medium
AirSpec uses pure Scala functions for writing test cases. ... Testing with simple assertions: assert(cond) , x shouldBe y , etc.
Read more >
Airframe Meetup #3: 2019 Updates & AirSpec - SlideShare
Custom Script Execution Environment on TD Workflow @ TD Tech Talk 2018-10-17. Muga Nishizawa ... Example: AirSpec Assertions 8; 9.
Read more >
FLASH User's Guide
and beyond, with hundreds of active users who customize the code for their own research. As of October 25, 2021, the Flash Center...
Read more >
infrared interferometer spectrometer: Topics by Science.gov
The airborne infrared spectrometer (AIR-Spec) will measure the coronal plasma emission lines in the infrared at high spatial and spectral resolution.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found