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.

Lifetime of an actors note when using mocha specs

See original GitHub issue

Hi @jan-molak,

I did some experiments with the new notes feature using Serenity/JS 3.0.0-rc18 and the mocha template, to keep it simple.

Given an Actor

  • using a notepad
  • that is not shared
  • that is either typed or untyped

then the note is just available in the mocha it block where it was set.

Though I’m in the same spec and in the same describe block, the note is not available when using an untyped note or set back to the initial value when using the typed notepad.

Is this intended? This is basically the scenario which led to my question about the lifecylce of an actor.

As the the Actor gets configured here should the note not be available for an actor called by the same name?

To have the notes available I would have to use a shared notepad, but this would apply to all actors, wouldn’t it?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
viper3400commented, Jun 8, 2022

Thanks, Jan! This example with

  • using different notepads
  • for different actors
  • speaking different languages

finally helped me to understand the whole (technical) concept behind the actors (and their lifetime) a bit more.

1reaction
jan-molakcommented, Jun 7, 2022

initiate the actor in a before hook

means more or less to let an actorCalled(‘somehow’) perform his first Task.

Exactly. Well, technically speaking, even a call to actorCalled('somehow') without specificying the task would instantiate an actor. It’s a bit like initialising a constant before you do something with it.

Would it be possible to build a dependency? My attempt to engage both does not really work.

Right, that’s because the second call to engage resets the Cast set by the first call.

Remember, that you can always do something a bit simpler, which is to have one implementation of the Cast, and differentiate between the actors based on their names.

For example:

class Actors implements Cast {
  prepare(actor: Actor): Actor {
    switch(actor.name) {
      case 'Jean':
        return actor.whoCan(TakeNotes.using(Notepad.with(this.translationsIn('fr-FR'))))
      case 'John'
        return actor.whoCan(TakeNotes.using(Notepad.with(this.translationsIn('en-GB'))))       
      default:
        return actor.whoCan(TakeNotes.using(Notepad.with(this.translationsIn('de-DE'))))
    }
  }
  
  private translationsIn(locale: string) {
      return ...
  }
}

(Maybe, I should also take into account, that one it block should not depend on another one, anyway …)

Yeah, I’d suggest avoiding test scenarios depending on the order of execution, since that prevents people from executing scenarios individually.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mocha: create and finalize test programmatically
To integrate with mocha this implementation describes a custom mocha interface to proxy test results from tests executed in another environment ...
Read more >
mocha/mocha.js - chromium/src/third_party - Git at Google
Note : cannot use `length < kMaxLength()` here because that fails when. // length is NaN (which is otherwise coerced to zero.).
Read more >
2017-22-LORT-AEA-Agreement-Unsigned.pdf
Agreement, requests the removal of any arbitrator by notice in writing ... If the Actor is required to use body make-up, the Theatre...
Read more >
Actor - | Serenity/JS
Retrieves actor's Ability to doSomething . Please note that this method performs an instancepf check against abilities given to this actor via Actor#whoCan....
Read more >
Oral and Long-Acting Injectable Cabotegravir and Rilpivirine ...
Note : For Cohort 1 Step 2 participants, body weight will not be exclusionary for enrollment into Cohort 2 Step 3, if otherwise...
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