First of all, I cannot upgrade to 3.0 due to dev environment.
Now the problem is as follows: I have a mixin that contains a function that is used multiple times amongst several elements:
'use strict';
(() => {
Polymer.helperUtils = {
helperFunction(lol, asd) {
return lol+asd;
},
};
})();
I then use this in another element:
'use strict';
class UsingHelp extends Polymer.mixinBehaviors(
[Polymer.helperUtils],
Polymer.Element
) {
static get is() {
return 'using-help';
}
static get properties() {
...
}
usingtheHelp() {
const lol = 1;
const asd = 2;
return this.helperFunction(lol, asd);
}
When running the app, this works without a flaw, no errors on the console, app uses the helper function as required. However, when I'm testing the UsingHelp
element, the function cannot be found!
<!doctype html>
<html>
<head>
...imports etc...
</head>
<body>
<test-fixture id="using-help-fixture">
<template>
<using-help></using-help>
</template>
</test-fixture>
</body>
<script>
it('should comply to my test', () => {
doSomethingThatRequiresUsingtheHelpToRun();
}
</script>
This will throw an error pointing to using-help.js
, stating this.UsingHelp is not a function
.
Why does the mixin behaviour not work when it's being called from the test and how do I fix this?
Aucun commentaire:
Enregistrer un commentaire