These are chat archives for rosshinkley/nightmare

18th
Jul 2016
Nannooskeeska
@Nannooskeeska
Jul 18 2016 14:47
Is there a way to use if statements to check the URL and do something depending on what it is? On our work network, we occasionally have to log in to ZScaler to access a website, and I'm running into an issue with that using Nightmare
Ross Hinkley
@rosshinkley
Jul 18 2016 14:48
depends on how you have things set up, but sure
using promises, you could do something like...
Promise.resolve(url)
  .then((url) => {
    if(condition){
      return nightmare.goto(url).screenshot() ...
    } else {
      return nightmare.goto(somewhereElse) ...
    }
  })
  .then((result) => { ...
Mingsterism
@mingsterism
Jul 18 2016 14:54
hey Ross. was wondering do you know any resources/references to lookup for mongo Native drivers. Was hoping to implement those with Nightmare
Ross Hinkley
@rosshinkley
Jul 18 2016 14:54
oooohhhh, good question
giving up on Mongoose? :)
Mingsterism
@mingsterism
Jul 18 2016 14:55
well, i can still use mongoose but wanted to use mongo native too
i think its performance is better no?
Ross Hinkley
@rosshinkley
Jul 18 2016 14:55
in general, i suppose
Nannooskeeska
@Nannooskeeska
Jul 18 2016 14:55
Thanks Ross!
Ross Hinkley
@rosshinkley
Jul 18 2016 14:55
@Nannooskeeska no problem :)
@mingsterism i would point out, though, if you're worried about performance, Nightmare is probably going to be your bottleneck
that said...
Nannooskeeska
@Nannooskeeska
Jul 18 2016 14:58
Will that work with Mocha/Chai testing as well? Basically what I want to do is ```
if(url === zscaler) {
login to zscaler
else {
woooops
do other stuff haha
Ross Hinkley
@rosshinkley
Jul 18 2016 14:58
yeah, so long as the last .then() calls .done()
er
done()
Nannooskeeska
@Nannooskeeska
Jul 18 2016 14:59
Gothca
Mingsterism
@mingsterism
Jul 18 2016 14:59
is reading mongo cookbooks useful?
Nannooskeeska
@Nannooskeeska
Jul 18 2016 14:59
I'll try it out
Ross Hinkley
@rosshinkley
Jul 18 2016 14:59
if you're using mocha, you might want to take a peek at mocha-generators and the Nightmare unit tests
Nannooskeeska
@Nannooskeeska
Jul 18 2016 14:59
Gotcha*
Ross Hinkley
@rosshinkley
Jul 18 2016 15:00
@mingsterism i assume you don't mean the chef files?
:P
Nannooskeeska
@Nannooskeeska
Jul 18 2016 15:00
Mingsterism
@mingsterism
Jul 18 2016 15:00
oh. not that.
Ross Hinkley
@rosshinkley
Jul 18 2016 15:01
@Nannooskeeska that looks right
Mingsterism
@mingsterism
Jul 18 2016 15:01
is mongo native recommended to use with nightmare? or is it difficult
Ross Hinkley
@rosshinkley
Jul 18 2016 15:02
@mingsterism mongo native is fine, it's really a matter of what you want to do and how much sugar you want around reading and writing your data
Mingsterism
@mingsterism
Jul 18 2016 15:02
alright got it. btw. do you know anyplace that shows some examples of mongo native
Ross Hinkley
@rosshinkley
Jul 18 2016 15:03
mongoose makes relations, validation, and loading quite a bit simpler
(and i'm sure half a dozen other things i'm not thinking of off the top of my head)
but it might be a bit heavy-handed in certain circumstances
the official driver would probably be a good place to start
Mingsterism
@mingsterism
Jul 18 2016 15:05
i see. ok.
thanks Ross :)
Ross Hinkley
@rosshinkley
Jul 18 2016 15:05
no problem :)
also
if you want a nice sort-of-kind-of middle ground
that uses promises in its implementation
monk might be a good option
Mingsterism
@mingsterism
Jul 18 2016 15:06
interesting.
thanks
Ross Hinkley
@rosshinkley
Jul 18 2016 15:06
no problem :)