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.

Allow context in before hook

See original GitHub issue

It would be useful to have context available in before hooks, so that messy workarounds like in https://github.com/avajs/ava/issues/1542 aren’t required. It’s useful in cases where you’re doing integration testing and are downloading several URLs whose content will be used across multiple tests.

Without being able to share context in before hooks you would need to resort to the workaround, or download the page for each test each time, even though the content doesn’t change between tests.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
novemberborncommented, Feb 6, 2018

The functionality has landed in #1657 but it still needs to be documented. @kugtong33 is awesome and on the case though!

0reactions
kugtong33commented, Jan 26, 2018

@novemberborn

These are the steps of what I understood about the problem

  • create the context object before passing it to the before hook
  • clone context using Object.create then pass it to the beforeEach hook if there is one, else pass it to the test so that each test will have their own clone of context
Read more comments on GitHub >

github_iconTop Results From Across the Web

RSpec 3 RuntimeError: "let declaration accessed in a `before ...
You can't refer to a let variable (or subject ) in a before(:all) / before(:context) hook. Doing so was deprecated in RSpec 2...
Read more >
Shared contexts that access a `let` method in a before hook ...
You have a shared context that defines a let method. That shared context accesses the let method in a before hook. The example...
Read more >
`before` and `after` hooks - RSpec Core 3.9 - Relish
Use before and after hooks to execute arbitrary code before and/or after the body of an example is run: before(:example) # run before...
Read more >
What are Cucumber Hooks And How to Use ... - Tools QA
Cucumber supports hooks, which are blocks of code that run before or after each scenario. You can define them anywhere in your project...
Read more >
Context - React
When to Use Context; Before You Use Context ... Every Context object comes with a Provider React component that allows consuming components to...
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