Conversation
test/index.test.js
Outdated
| }) | ||
|
|
||
| describe('my probot app', () => { | ||
| let app |
There was a problem hiding this comment.
Can this be let app, github? Or do you prefer it like this (I prefer the first, but I won't die on this hill)
There was a problem hiding this comment.
done! We should also update this in the docs and anywhere else it's used for consistency
test/index.test.js
Outdated
| // const index = require('../index') | ||
| const { Application } = require('probot') | ||
| // Requiring our app implementation | ||
| const plugin = require('..') |
There was a problem hiding this comment.
I don't think we should use plugin here. I'd prefer to rename this to app and rename app to probot.
There was a problem hiding this comment.
🤔 Hm, but the class is called Application, so that would look like this:
const { Application } = require('probot')
const probot = new Application()
const app = require('..')
...
probot.load(app)
We do tend to call these plugins elsewhere (like the 3 default plugins for stats, sentry, and the default website). But I see the confusion since we do module.exports = app => {...}. I'm inclined to leave it as plugin and maybe explain that reasoning a little better in the docs?
There was a problem hiding this comment.
I'm having flashbacks to probot/probot#210 but I think we should be very certain about our language choices before merging this, since everyone will use that language once we do it.
I also don't think that code snippet is all that horrible sounding, but I'm open to other thoughts.
There was a problem hiding this comment.
I agree with @tcbyrd that that code snippet is confusing - I'd expect app to be an instance of Application, just based on the naming.
However, I agree that plugin is 👎, especially because of that issue @hiimbex was kind enough to link to. Some other ideas:
applicationFunction(which is actually the TS name)appFunctionmyAppmyProbotApp- Fill this with a camel-cased version of their app name, as part of the
create-probot-appscript
There was a problem hiding this comment.
I think all of these are good options, but the idea of mimicking the actual TS name sounds the best to me. But I don't have strong opinion on this except to not use plugin
There was a problem hiding this comment.
I think what we're struggling with here is the default export of the template doesn't have an app name. What we should probably be encouraging is using the name of the app instead of "plugin".
So for TODO:
const { Application } = require('probot')
const app = new Application()
const todo = require('..')
app.load(todo)
or WIP:
const { Application } = require('probot')
const app = new Application()
const wip = require('..')
app.load(wip)
I like using applicationFunction because it's the best description of the general term, but maybe we could leave a comment that it could be whatever your name your app?
There was a problem hiding this comment.
@tcbyrd, thanks for finding those examples. Given that we name the variable after our apps, it sounds like this idea would be the best, but also the most effort to implement:
Fill this with a
camel-casedversion of their app name, as part of thecreate-probot-appscript
There was a problem hiding this comment.
One concern of this approach is that it kind of breaks if folks name their probot app just "app" or any other reserved word, but not sure if that is a huuuge problem.
Another option is to use myProbotApp instead of plugin?
|
2 questions I have before we merge this:
I'm starting to learn more towards sticking with a generic name 🤔 |
I'm not sure I follow.
I'm not convinced this is a common enough issue to deal with, but willing to hear other opinions on this. |
Instead of |
It's funny because this actually happened to me while testing this new template. I created a probot app called "test" and of course that broke things because it's a reserved word in Jest 🤣. Took me a while to realise what was going on 😅 |
|
Thoughts on switching the This would also align with the example from the Probot testing docs: https://probot.github.io/docs/testing/ |
I think I personally prefer
It feels like after this PR is merged, we'll update that code snipped accordingly to bring the two in line
|
Hmm, yeah, that does seem to be the case. I'm so used to unit test frameworks with
Yes, that would definitely be ideal. 👍 |
The test currently included as part of the template is not super helpful for folks getting started with testing their probot apps. The intention of this PR is to make it a little bit easier for them by providing a working example that they can use as a starting point and either copy, modify, or extend.
The example is basically the same as the one presented in the docs, with some minor tweaks.
This PR also adds the "Hello World" example from the probot/probot README to index.js which should make it even easier for folks to get started.