What is the deno equivalent of node --check - deno

In node there is a --check option to check if code is valid for execution without actually running it if valid.
I have been looking for an equivalent in deno (deno help, deno run help, deno lint help)
The closest i can figure out is deno lint, but it will happily lint the following typescript code (in test.ts), which deno run subsequently refuses to run (obviously).
What is the canonical deno "dry run"?
test.ts:
const message = "hello!";
message();

check if code is valid for execution
"dry run"
These concepts don't exist. I think what you want is to have your TypeScript code analyzed using static type-checking (without actually running the module). This is called compilation and the Deno subcommand you want in this case is cache:
deno cache module.ts
Re-cache the entrypoint module and all dependencies:
deno cache --reload module.ts
Using your example test.ts:
% deno cache test.ts
Check file:///Users/deno/test.ts
error: TS2349 [ERROR]: This expression is not callable.
Type 'String' has no call signatures.
message();
~~~~~~~
at file:///Users/deno/test.ts:2:1

Related

How do you get Deno to use the DENO_AUTH_TOKENS environment variable?

Using the DENO_AUTH_TOKENS environment variable doesn't appear to work for me. I've created a personal access token from GitHub and added it to my environment as described in the private modules page of the Deno manual. However, I still just get a 404 error:
error: Import 'https://raw.githubusercontent.com/MYCOMPANY/MYREPO/main/MYFILE.ts' failed: 404 Not Found
I've verified that the token is in the environment variable, and it succeeds in curl by executing the following:
curl -s https://$DENO_AUTH_TOKENS/MYCOMPANY/MYREPO/main/MYFILE.ts
Am I doing the import differently than the Deno runtime expects it?
import { foo } from 'https://raw.githubusercontent.com/MYCOMPANY/MYREPO/main/MYFILE.ts';
Running the script with -L debug gives a lot of verbose logging, but nothing about tokens at all.
What does it want me to do?
$ deno --version
deno 1.14.2 (release, x86_64-apple-darwin)
v8 9.4.146.16
typescript 4.4.2
This was a dumb mistake. When I added the variable to my .profile file, I forgot to add export before. It works after adding that:
export DENO_AUTH_TOKENS=aaaaaaaaaaaaaaaaaa#raw.githubusercontent.com

Vague error in Vercel deployment (exit with code 1)

So normally Vercel gives me decent error messages, but this one seems to have no detail. Just
"failed with exit code 1".
For context, I just started this project w the basic NextJS template, made a few modifications, and this is my first deploy.
Failed once and I assumed it was because NextJS has strict type checking on by default, so I modified the next.config.js file as follows (per here):
module.exports = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
};
But still failed. Here is the full log:
10:23:27.575 Cloning github.com/lawderp/physical (Branch: main, Commit: 8f97554)
10:23:28.589 Cloning completed: 1.014s
10:23:28.614 Analyzing source code...
10:23:29.739 Installing build runtime...
10:23:31.612 Build runtime installed: 1.873s
10:23:34.043 Looking up build cache...
10:23:34.164 Build cache found. Downloading...
10:23:35.100 Build cache downloaded [21.48 MB]: 936.007ms
10:23:36.250 Installing dependencies...
10:23:36.489 yarn install v1.22.11
10:23:36.547 [1/4] Resolving packages...
10:23:36.734 success Already up-to-date.
10:23:36.743 Done in 0.26s.
10:23:36.754 Detected Next.js version: 11.1.2
10:23:36.755 Running "yarn run build"
10:23:37.021 yarn run v1.22.11
10:23:37.047 $ next build
10:23:37.820 info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
10:23:37.976 info - Skipping validation of types...
10:23:40.439 error Command failed with exit code 1.
10:23:40.439 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
10:23:40.456 Error: Command "yarn run build" exited with 1
Still not sure what the issue was but eventually figured out how to get past this - ignored ESLint during build by adding the following to next.config.js:
eslint: {
ignoreDuringBuilds: true,
},
(I don't advise doing this but this was quick low-stakes experiment)
I received the same vague message after making eslint alterations. Locally linting and deployment was successful, however deploying to vercel failed like yours.
Although "ignoreDuringBuilds": "true" in my .eslint.json did band-aid fix the issue, I was able to rollback each eslint change and found that my "linebreak-style": ["error", "windows"] was the underlying issue.
It passed linting locally, but failed on vercel deployment. I've fixed my line-breaks and all works great now without having to ignore during builds.

Why does deno's exec package execute commands without outputting messages to the terminal?

import { exec } from "https://deno.land/x/exec/mod.ts";
await exec(`git clone https://github.com/vuejs/vue.git`)
when i use git clone https://github.com/vuejs/vue.git in .sh file, It has message in terminal,
but don't have in deno
First, I think it is important to echo what jsejcksn commented:
The exec module is not related to Deno. All modules at https://deno.land/x/... are third-party code. For working with your shell, see Creating a subprocess in the manual.
Deno's way of doing this without a 3rd party library is to use Deno.run.
With that said, if you take a look at exec's README you'll find documentation for what you're looking for under Capture the output of an external command:
Sometimes you need to capture the output of a command. For example, I do this to get git log checksums:
import { exec } from "https://deno.land/x/exec/mod.ts";
let response = await exec('git log -1 --format=%H', {output: OutputMode.Capture});
If you look at exec's code you'll find it uses Deno.run under the hoods. If you like exec you can use it but you might find you like using Deno.run directly instead.

TestCafe integration with cucumber - test cases in github project time out

I have been experimenting with javascript frameworks for test automation and one of them is testCafe. I have been able to set up a simple TestCafe project and run some test cases for my application. However, now, the requirement is to have some kinda BDD support built in it. I looked up a few testCafe-cucumber integration projects on GitHub but I can't get them to run. here are a few that I tried:-
1) https://github.com/rquellh/testcafe-cucumber
- I cloned the repo,
- did npm install,
- run the test cases using "npm test",
- blank browser launches but test doesn't run. I see this error in VS code console:
× Before # features\support\hooks.js:46
Error: function timed out, ensure the promise resolves within 20000 milliseconds
at Timeout._onTimeout (C:\Users\Mo\Desktop\TestCafe\github\testCafeBDD\testcafe-cucumber\node_modules\cucumber\src\user_code_runner.js:61:18)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)
× After # features\support\hooks.js:60
ReferenceError: testController is not defined
Then I tried another gitHub project namely this one : https://github.com/kiwigrid/gherkin-testcafe
the run command in readme doesn't work for me, it doesn't even recognize the "gherkin-testcafe".
When I run my TestCafe test cases without the cucumber I have this line in my package.json
"scripts": {
"test": "testcafe chrome Tests/ -e --proxy https.proxy.mycompany.com:8000"
},
the proxy is mentioned because I am behind a proxy and without this the browser launches but does not run any test cases. I found this fix on testCafe site
I am guessing(not sure yet) this could be the issue with cucumber integration as well. None of these frameworks work as they don't set up the proxy anywhere. Can someone point me in the right direction? if the proxy needs to be set up then where in the framework does it need to go- an example would be helpful?
TestCafe/Cucumber integrations rely on starting TestCafe runner programmatically.
In the repo, search for this sequence:
const runner = tc.createRunner();
return runner
.src('./test.js')
.screenshots('reports/screenshots/', true)
.browsers(browser)
.run()
.catch(function(error) {
console.error(error);
});
or search for this sequence:
await runner
.browsers(browsers)
.specs(specs)
.steps(steps)
.concurrency(concurrency)
.startApp(app, appInitDelay)
.tags(tags)
.run(...)
Chain the useProxy method on runner object (do it before the run()method):
const runner = tc.createRunner();
return runner
.src('./test.js')
.screenshots('reports/screenshots/', true)
.browsers(browser)
.useProxy('username:password#proxy.mycorp.com')
.run()
.catch(function(error) {
console.error(error);
});

nightwatch - terminate all test suits when a single test fails

Is there a way (e.g. flag) to terminate whole nightwatch tests when a single failed test occur? Or to get at least a status code that the some test failed, within the program?
Thanks!
In your "test_settings" section of your nightwatch.json, add the following entry:
"end_session_on_fail": true
It looks promising.
You can also try creating a global in global.js and set it to true:
"abortOnAssertionFailure: true"
You can run each test suit by different npm script, such as-
"test1": "nightwatch --retries=1 ./src/tests/test1.js",
"test2": "nightwatch --retries=1 ./src/tests/test2.js"
and then you can run this npm script-
"run_tests": "npm run test1 && npm run test2"
is one test case will fail in 'test1' the npm command will fail as well and no other tests case/suits will run.

Resources