Testing functions in Haskell that do IO

You can make your code testable by using a type-class-constrained type variable instead of IO. First, let’s get the imports out of the way. {-# LANGUAGE FlexibleInstances #-} import qualified Prelude import Prelude hiding(readFile) import Control.Monad.State The code we want to test: class Monad m => FSMonad m where readFile :: FilePath -> m String … Read more

How to identify and switch to the frame in selenium webdriver when frame does not have id

driver.switchTo().frame() has multiple overloads. driver.switchTo().frame(name_or_id) Here your iframe doesn’t have id or name, so not for you. driver.switchTo().frame(index) This is the last option to choose, because using index is not stable enough as you could imagine. If this is your only iframe in the page, try driver.switchTo().frame(0) driver.switchTo().frame(iframe_element) The most common one. You locate your … Read more

How do I test private methods in Rust?

When using #[test], there’s nothing special about private or public methods—you’re just writing perfectly normal functions that can access anything they can access. fn private_function() { } #[test] fn test_private_function() { private_function() } External tests, such as tests/*.rs and examples/*.rs if you’re using Cargo, or doc tests, do not get access to private members; nor … Read more

How to ignore classes in test class with ArchUnit

It seems that the API is not guiding very well with respect to this, because you’re not the first one wondering about this (this was also issue #1 on Github https://github.com/TNG/ArchUnit/issues/1). To answer the question though, the Annotation @AnalyseClasses has an extra attribute importOptions, which takes arbitrary implementations of ImportOption. There you can specify which … Read more

How to assert function invocation order in jest

The solution by clemenspeters (where he wanted to make sure logout is called before login) works for me: const logoutSpy = jest.spyOn(client, ‘logout’); const loginSpy = jest.spyOn(client, ‘login’); // Run actual function to test await client.refreshToken(); const logoutOrder = logoutSpy.mock.invocationCallOrder[0]; const loginOrder = loginSpy.mock.invocationCallOrder[0]; expect(logoutOrder).toBeLessThan(loginOrder)