gemini-testing / gemini

💀💀💀[DEPRECATED] Use hermione
https://github.com/gemini-testing/hermione
MIT License
1.5k stars 149 forks source link

Execute before() or after() without call to capture() #919

Open wabisabit opened 6 years ago

wabisabit commented 6 years ago

Gemini version 5.7.2

I'm using executeJS in order to set a localStorage item for the next suite as explained here: https://github.com/gemini-testing/gemini/issues/799

Although it works, in my case, I don't want to capture anything in the first suite, so using before or after instead of capture would make more sense. But without a call to capture the actions are ignored.

gemini.suite( 'Login (capture unwanted)', suite => {

  suite
    .setUrl( 'index.html' )
    .before( function( actions, find ) {

      actions.executeJS( function( window ) {
        window.localStorage.setItem( 'user', 'data' );
      } );

    } );

} );

gemini.suite( 'Logged-in app', suite => {

  suite
    .setUrl( 'index.html' )
    .setCaptureElements( 'html' )

    .capture( 'plain' )
} );

Command used to run the test:

gemini test

Result: The localStorage item is unavailable in the second suite

Expected behaviour: The localStorage item is available in the second suite

FrEaKmAn commented 5 years ago

I think you need to wrap second suite inside first one as described in Nested tests - https://gemini-testing.github.io/doc/tests.html#nested-suites to be able to access stored localStorage

wabisabit commented 5 years ago

Thank you @FrEaKmAn I'll try that.