Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 14 20:01
    greenkeeper[bot] labeled #5450
  • Dec 14 20:01
    greenkeeper[bot] opened #5450
  • Dec 14 20:00

    greenkeeper[bot] on semver-7.0.0

    chore(package): update semver t… (compare)

  • Dec 14 16:58
    millette starred canjs/canjs
  • Dec 14 00:14
    greenkeeper[bot] labeled #5449
  • Dec 14 00:14
    greenkeeper[bot] opened #5449
  • Dec 14 00:14

    greenkeeper[bot] on can-super-model-2.0.0

    fix(package): update can-super-… (compare)

  • Dec 14 00:13
    greenkeeper[bot] labeled #5448
  • Dec 14 00:13
    greenkeeper[bot] opened #5448
  • Dec 14 00:13

    greenkeeper[bot] on can-define-rest-model-2.0.0

    fix(package): update can-define… (compare)

  • Dec 14 00:12
    greenkeeper[bot] labeled #5447
  • Dec 14 00:12
    greenkeeper[bot] opened #5447
  • Dec 14 00:12

    greenkeeper[bot] on can-define-realtime-rest-model-2.0.0

    fix(package): update can-define… (compare)

  • Dec 14 00:07
    greenkeeper[bot] labeled #5446
  • Dec 14 00:07
    greenkeeper[bot] opened #5446
  • Dec 14 00:07

    greenkeeper[bot] on can-connect-ndjson-2.0.0

    fix(package): update can-connec… (compare)

  • Dec 13 21:27

    greenkeeper[bot] on @octokit

    (compare)

  • Dec 13 21:25

    greenkeeper[bot] on @octokit

    chore(package): update @octokit… (compare)

  • Dec 13 21:21

    greenkeeper[bot] on @octokit

    (compare)

  • Dec 13 21:20

    greenkeeper[bot] on @octokit

    chore(package): update @octokit… (compare)

Kevin Phillips
@phillipskevin
there is CanSymbol.iterator
Gregg Roemhildt
@roemhildtg
If I add that, it'll call that function in stache for of ?
Kevin Phillips
@phillipskevin
you're trying to create your own observable you mean?
Gregg Roemhildt
@roemhildtg
Correct. Its kind of like an array...it has a toArray method, and a length property but its not like a normal array where you can do array[0]. So I thought I'd build an iterator function
Kevin Phillips
@phillipskevin
you would need more symbols than that
definitely isObservableLike and isListLike
not sure what else
Andrei Balmus
@abalmush
Hi guys, does anyone has experience with intergating Jest in canjs app?
Gregg Roemhildt
@roemhildtg
I've done this @abalmush
Jest works super well testing view models
Andrei Balmus
@abalmush
@roemhildtg do you have an example especially how to configure it
I have quite old project with canjs 2.3 )
Gregg Roemhildt
@roemhildtg
Weeeeelll, I haven't really needed to configure anything with Jest. That being said I'm writing stuff in es6 now so everything just works.
I'm also using canjs 5
Andrei Balmus
@abalmush
and I tried to get it to work, looks like the instance of canjs inside Component is differetn and I see warning somethig saying that this component is not registered
yeah with Canjs5 should work pretty well
Gregg Roemhildt
@roemhildtg
Ah, so you're trying to test the components? I haven't done that yet. Just viewModel testing so far. Like logic and whatnot. Functional testing is a whole new level for me
Andrei Balmus
@abalmush
yeah yea exatly I’m trying to render it using stache and check if everything is rendered. Same way as with React component )
Gregg Roemhildt
@roemhildtg
Yeah. Its on my todo list to look into that.
Andrei Balmus
@abalmush
Please let me know if you figure it out, I’ll post a message here as well
Gregg Roemhildt
@roemhildtg
:thumbsup:
Guido Smeets
@gsmeets
I am using mocha, but the principles are the same I reckon
I've made a few helper functions to easily render a component. The only tricky part is when you have fixtures for your data, which are collected async. So you need to add some promise to your viewmodels to ensure that they're loaded. I've done that generically for all my "functional" components.
Kevin Phillips
@phillipskevin
@abalmush can you post the error you're seeing?
Andrei Balmus
@abalmush
Hi @phillipskevin ok sure I will post it later, today.
Kevin Phillips
@phillipskevin
:thumbsup:
Andrei Balmus
@abalmush
I configured it from scratch, and I’m gettin another error:
Screen Shot 2018-09-15 at 11.09.21 PM.png
and this is the component it self
Screen Shot 2018-09-15 at 11.11.34 PM.png
that looks like something different, before it was that Jest didn’t see component initialization
I will try to reproduce later
Marc Godard
@MarcGodard
I have seen a way to do this, but cannot remember. I have a viewmodel variable that defaults to null, then gets set (this is a session type variable). Then in another viewmodel, once that is set, I want to update a variable, using get (). Just can't figure out how to do that anymore.
Any one know?
Andrei Balmus
@abalmush
@MarcGodard you can find a model of the component using can.viewModel - https://canjs.com/doc/can-view-model.html
Kevin Phillips
@phillipskevin
@abalmush are you using steal somewhere in your code?
Andrei Balmus
@abalmush
HI @phillipskevin nope, it comes from canjs package map/backup/backup
as per stack trace
if I creat component inside my test file no issues )
The only thing I do in my code is this: import ‘can/map/backup/backup’;
so I can backup my Map and restore it if needed
Kevin Phillips
@phillipskevin
ok, I'll take a look
oh, just because all can packages are using steal syntax in 2.x
Andrei Balmus
@abalmush
OK sure thank you. Btw this is old canjs 2.3
yeah
Kevin Phillips
@phillipskevin
I'm not sure exactly how to configure Jest to work with this global variable
I'm sure someone has done it hough
Andrei Balmus
@abalmush
Yeah, I will return back to this issue and try to resolve it some urgent stuff popped up and I have to postpone it.
Kevin Phillips
@phillipskevin
ok
@MarcGodard you would do something like this
// parent-view-model.js
ViewModel: {
    sessionPromise: {
        default() {
            return Session.get({});
        }
    }
}
// child-view-model.js
ViewModel: {
    sessionPromise: "any",

    session: {
        get(lastSet, resolve) {
            if (this.sessionPromise) {
                this.sessionPromise.then(resolve);
            }
        }
    }
}