I just installed Protractor v2.0.0
. I tried to add beforeAll
to a test and got error
ReferenceError: beforeAll is not defined
Looking at the the stacktrace I see jasmine 1.3.1 is a submodule of protractor:
C:\Users\bmackey\AppData\Roaming\npm\node_modules\protractor\node_modules\minijasminenode\lib\jasmine-1.3.1.js:913:21
beforeAll
is introduced in jasmine 2.1. I tried npm i -g jasmine-before-all
to no avail. How can I get this functionality to work?
The purpose of this article is to describe the behavior of the beforeAll and beforeEach functions in a Jasmine spec. beforeAll and beforeEach , along with afterAll and afterEach, are Jasmine global functions that can be used manage expensive setup and teardown in test suites.
The beforeAll function executes once and only once for the describe block containing it, before any of the beforeEach functions or any of the specs. The beforeEach function executes before any spec in the describe block containing it, as well as before any spec contained inside any inner describe. You'll see this in A More Complex Example below.
2. @BeforeAll and @AfterAll in Non-Static Methods While unit testing, we may occasionally want to use @BeforeAll and @AfterAll in non-static setup and tear-down methods — for instance, in a @ Nested test class or as interface default methods. Let's create a test class with the @BeforeAll and @AfterAll methods as non-static:
@BeforeEach and @BeforeAll are the JUnit 5 equivalents of @Before and @BeforeClass. These annotations were renamed with clearer names to avoid confusion. Let's duplicate our previous classes using these new annotations, starting with the @BeforeEach and @AfterEach annotations:
Protractor is still using jasmine1
by default. You have to set jasmine version in your config
framework: 'jasmine2',
You can find more information in the reference configuration file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With