On the Jasmine website I see that we can disable suites by xdescribe
or individual specs by xit
. Is there a way to disable only an expectation (like xexpect
)?
The reason why I'm asking this is because I'm writing e2e tests with Protractor and in our continuous integration we don't yet (if ever) have access to the database, though locally we can run real end to end tests with access to the database, for example.
I would like to mark individual expectations as optional, depending on a configuration or environment variable. It would be nice to make a switch once, and then create a wrapper around expect, that only fails if we are running the tests locally (with access to the database).
So for example I can create a new spec family:
if (process.env.DB_AVAILABLE) {
dbit = it;
} else {
dbit = xit;
}
and write specs that depend on database connection as following:
dbit('creates new user', function () {});
Is there a way to do the same with expect
(e.g. dbexpect
)?
If there is something fundamentally wrong with my approach, don't hold it back and let me know.
expect
statement -- but you could possibly usebrowser.getProcessedConfig()
and check theseleniumAddress
and do conditionalexpect
's (assuming you have 2 configs, one for local and one for the CI server).if(local) { expect(true).toBe(true) } else { expect(false).toBe(false) }
... but this might be costly if you are doing it in a lot of places. – Linkmanit
to a variable based on environment... thanks for that :) – Linkman