Is it possible to use the browser console in a Tinytest context? - meteor

cd ~/my-package
meteor test-packages ./
open localhost:3000
I can't seem to use the JS console: Even though Meteor can be logged from a client test file, when I enter it in the console, I get VM10740:1 Uncaught ReferenceError: Meteor is not defined. Same goes for other objects like Accounts.
I'd like access to these variables and those defined in my package and tests file in order to debug my tests.
EDIT: In the client test file, this works:
window.Meteor = Meteor
window.Accounts = Accounts
...
Is there a better way? Or at least a way that automatically goes through all globals? Trying this caused a refresh loop: _.extend(window, this)

Related

Changing firestore-debug.log location

I have a watcher in my Firebase project that automatically compiles and restarts the emulator whenever I change my code. It's nice except I think because of some race conditions I get a new firestore-debug.log or asidfhusudf.log file every time I save my code. How can I disable the log files or at least change the location where they are made?
firestore-debug.log is present in the same folder as firebase.json. You can see it in the directory you ran the command which will have a log of all the requests.
You are using typescript for functions so you can refer to the documentation on how function logs works for Typescript projects :
During firebase deploy, your project's index.ts is transpiled to index.js, meaning that the Cloud Functions log will output line numbers from the index.js file and not the code you wrote. To make it easier for you to find the corresponding paths and line numbers in index.ts, firebase deploy creates
functions/lib/index.js.map. You can use this source map in your preferred IDE or via a node module.
How debug output is stored in the firestore-debug.log is mentioned in the Documentation :
A basic debug function that prints Security Rules language objects, variables and statement results as they are being evaluated by the Security Rules engine.The outputs of debug are written to firestore-debug.log.
The debug function can only be called inside Rules conditions.debug function blocks are only executed by the Security Rules engine in the Firestore emulator, part of the Firebase Emulator Suite. The debug function has no effect in production.Debug logfile entries are prepended by a string identifying the Rules language data type of the log output (for example, string_value, map_value).Calls to debug can be nested.Currently, the debug feature does not support the concept of logging levels (for example, INFO, WARN, ERROR).
You can also refer to the stackoverflow case where Kiana and Daniel have provided a brief explanation on how logs older than 1 month got disabled automatically.
You can see it directly within the Firebase console. When trying to choose the timestamp for the logs, logs older than 1 month are disabled, which means are
automatically deleted.
You can refer to the documentation for getting an understanding of how Query language is used to filter logs in the Emulator suite UI.
Currently, there's no way to change the location since it's hard coded: https://github.com/firebase/firebase-tools/blob/c0f7acc80e8c4c2d174f97c5c41d6114e192fd23/src/emulator/downloadableEmulators.ts#L205

Firebase Deploy causing multiple errors and not deploying

Hello I am following this tutorial in order to do push notifications to multiple devices at once in Expo React Native using Firebase's cloud functions. The push tokens are stored in my RealTime-Database, but when I attempt to integrate this step after running firebase login and firebase init, I updated my index.js file to contain this code. After saving this file, I attempt to do firebase deploy and I get 70 errors. I tried to deploy it from my app directory, and didnt work, and I tried to do it from my functions directory and that didn't work. I deleted my node_modules and package-lock, and I tried to rerun expo again and clearing my npm cache. Nothing worked. I already had my firebase app initialized somewhere else, could that be the reason why? But my App itself still works, so I am not getting an error saying that the Firebase app is being initialized twice. I really dont know what else do to. Is the ESLint causing all of these errors? Should I run firebase init again without adding ESLint? Please let me know. My errors are below.
When deploying your code, by default, your code is linted using a tool called ESLint.
The "errors" you see are eslint complaining about trivial things like missing semicolons at the end of a line, using ' instead of ", improperly indented code, among other things. If you ever don't understand what a rule is trying to do, you can visit https://eslint.org/docs/rules/{rule-name} (such as https://eslint.org/docs/rules/semi).
As shown in the error message, you can use eslint . --fix to automatically fix most of these. Just enter into your functions directory and execute eslint . --fix.
Most IDEs have a keyboard shortcut for automatically formatting your code to your rules. In VSCode for example, this shortcut is Alt+Shift+F.

console.log in .meteor directory

Sometimes I want to analyze how things works in a meteor app and I wish I could output logs in the .meteor directory. But If I add a console.log() there, it never shows. Is there a way to do so?
As of the current version of Meteor, you can use a normal debugger on the server side using meteor debug. (You could always use the debugger client-side by using the Web Inspector.)

Can't use mongo commands in console anymore

I used to be able to use the Chrome Tools Console to type in Mongo commands on my Meteor app and see the results. Stuff like, Collection.findOne({name: "foo"}). It is also done this way in the tutorials on the Meteor site.
Now, for any mongo commands, I just get [collection] not defined. It makes debugging MUCH more difficult.
Perhaps something changed in the last few releases? Any insights?
Since Meteor 0.6.0 individual files are variable scoped. So if you have a collection defined via
var Collection = new Meteor.Collection("collection");
It won't be visible on the console anymore (but it will be visible in the file its defined in)
The workaround is to define the file globally which is just removing the var:
Collection = new Meteor.Collection("collection");
Then you should be able to access it on the chrome js console once again

[meteor][0.6.*] no data displayed whereas it's available in console

I've an application that is published on meteor hosting using command :
meteor deploy spyermeteor
The application is rendered on http://spyermeteor.meteor.com but no data is used on client side.
I can see that application is running well on server-side if i do a :
meteor logs spyermeteor
I then check the browser console and i see that i can access database :
Annonces.find().count() // per exemple
How do you explain that reactivity doesn't work on client-side ? maybe something is wrong with my conception but on my computer (windows) and on a VM (Linux debian) it works well.
Any help is welcome.
The source code is available here http://www.github.com/Rebolon/spyerMeteor
In production mode all files are concatenated and minified into one javascript file. If there is even a slight syntax error somewhere in your code the rest of the code will not execute.
Looking at your deployed site you have to split your client and server side code. I receive an error
Uncaught ReferenceError: Npm is not defined
This is meant to only run on the server but the code where you use Npm is being run on the client when it should only run on the server. It would also cause an error in production mode but since the files are not concatenated & minified the error wouldn't stop other javascript files from running.
You can either move this code to a file in /server or into a if(Meteor.isServer) {..} block
It also looks like your code is made for <= Meteor 0.5.9. You should upgrade your local instance to 0.6.2 and look for all these exceptions in your js console before you deploy your app.

Resources