Skip to content

How to perform Arithmetic Operations for the values fetched from the elements #2419

Discussion options

You must be logged in to vote

While #2420 will make it easier, you can already accomplish what you're after by writing a custom function producing a question that performs your desired computation:

import { Answerable, Question } from '@serenity-js/core'

const sum = (augend: Answerable<number>, addend: Answerable<number>) => 
  Question.about('sum', async actor => {
    const augendValue = await actor.answer(augend);
    const addendValue = await actor.answer(addend);
    
    return augendValue + addendValue;
  })
  
const difference = (minuend: Answerable<number>, subtrahend: Answerable<number>) => 
  Question.about('difference', async actor => {
    const minuendValue = await actor.answer(minuend);
    const subtr…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jan-molak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants