我不得不在JS中做一个站位提醒,但是我有一个问题,我有一个定义了注释的const,而且我不知道为什么,我尝试用console.log()
来理解为什么
我的代码是:
const q = require('daskeyboard-applet');
const logger = q.logger; // to access to the logger
class StandReminder extends q.DesktopApp {
// this method run () return a signal object
//we need to sent a signal here
async run() {
logger.info("Running.");
const reminder = this.config.reminder;
//I take the content of the JSON file with config
var counter = 0;
const color = '#00FF00';
console.log("the reminder is ", reminder);
if (counter >= reminder) {
counter = counter + 1;
} else {
return new q.Signal({
points: [
[new q.Point(color)]
],
name: 'Stand Reminder',
message: `${reminder}` //il prend bien la meme valeur que reminder
})
}
}
}
module.exports = {
StandReminder: StandReminder
}
const applet = new StandReminder();
问题在以下行
const reminder = this.config.reminder;
我编写了一个test.js以便使用yarn test
在终端上测试我的代码,代码是:
describe('#run()', () => {
it('sends a reminder from 30', async function () {
let app = new StandReminder();
let reminder = 30;
app.config.reminder = reminder;
return app.run().then((signal) => {
console.log(signal); passe jusque la
assert.ok(signal);
console.log(signal.message);
assert(signal.message.includes(reminder));
assert(signal.name.includes('Stand Reminder'));
}).catch((error) => {
assert.fail(error)
});
})
});
})
所以我尝试测试我是否有一个好的代码,但是当我在终端上测试该代码时,我的提示未定义,我不知道为什么你能帮助我?