---
# System prepended metadata

title: Course(Tools/Auto Testing/template)
tags: [deno, web]

---

# Course(Tools/Auto Testing/template)

###### tags: `web` `deno`

https://www.facebook.com/ccckmit/videos/8125394077533187/?idorvanity=266037214366597


https://www.facebook.com/ccckmit/videos/648351026859921?idorvanity=266037214366597

---


[TOC]


GO (fast)
cpython (C+python)
Dart + flutter(High portable :linux window android ios)




FrontEnd Framework
angularjs 
react
vue.js



deno fresh (inherit react)


---

# Tool

https://deno.land/manual@v1.27.2/tools/script_installer#script-installer


## Script Installer

Deno provides deno install to easily install and execute distribute code


### Static File Server 

example 
```
$ deno install --allow-net --allow-read https://deno.land/std@0.163.0/http/file_server.ts
```


fileServer
```
#!/bin/sh
# generated by deno install
deno "run" "--allow-read" "--allow-net" "https://deno.land/std@0.163.0/http/file_server.ts" "$@"

```

![](https://i.imgur.com/BloUeae.png)



## Code Formatter

Deno ship build-in code formatter that will auto-format the file.

```
\# format all supported files in the current directory and subdirectories
deno fmt
\# format specific files
deno fmt myfile1.ts myfile2.ts
\# format all supported files in specified directory and subdirectories
deno fmt src/
\# check if all the supported files in the current directory and subdirectories are formatted
deno fmt --check
\# format stdin and write to stdout
cat file.ts | deno fmt -
```


## Bundle

`deno bundle [URL]` will output a single JavaScript file for consumption in Deno, which includes all dependencies of the specified input.


```
deno bundle https://deno.land/std@0.163.0/examples/colors.ts colors.bundle.js
```

```
deno run colors.bundle.js
```


## Compiling Executables

`deno compile [--output <OUT>] <SRC>` will compile the script into a self-contained executable.



# Testing 


## Assert

The assert method is a simple 'truthy' assertion and can be used to assert any value which can be inferred as true.


```typescript
import { assert } from "https://deno.land/std/testing/asserts.ts";


Deno.test("Test Assert", () => {
    assert(1);
    assert("Hello");
    assert(true);
    assert(false);
  });
```


Assert Equality 

There are three equality assertions available, `assertEquals()`, `assertNotEquals()` and `assertStrictEquals()`.

The `assertEquals()` and `assertNotEquals()` methods provide a general equality check and are capable of asserting equality between primitive types and objects.



Notice: TDD(Test-driven development
)

## Auto testing (deno)

- puppeteer



# Template 


https://deno.land/x/dejs@0.10.3


-   <%= %\> Output escaped value
-   <%\- %\> Output raw value
-   <%# %\> Comment (nothing will be shown)
-   <% %\> Evaluate (use control flow like: if, for)



## Include partial ejs template 

we use include function 

`include` resolves views from relative path from **executed ts / js file**



Views/


Header 

```
<html>
<head>
  <title><%- title %></title>
</head>
<body>
```

content
```
<%- await include('views/header.ejs', { title: title }) %>
<h1><%=title%></h1>
<%- await include('views/footer.ejs') %>
```


footer 


```
</body>
</html>

```


index.ts

```typescript
import { renderFileToString } from "https://deno.land/x/dejs/mod.ts";

const output = await renderFileToString(`./views/contents.ejs`, {title:"Meowhecker"})

console.log(output)

```

---

Pass the data via the ejs 

> let users = {name:"meowhecker",password:"meowpassword"}

> let usersList = []


> usersList.push(users)

> usersList
[ { name: "meowhecker", password: "meowpassword" } ]


> let passDataViaObjectOfArrayOfobject = {Member:userList}


> passDataViaObjectOfArrayOfobject
{ Member: [ { name: "meowhecker", password: "meowpassword" } ] }

> passDataViaObjectOfArrayOfobject.Member
[ { name: "meowhecker", password: "meowpassword" } ]

> passDataViaObjectOfArrayOfobject.Member[0]
{ name: "meowhecker", password: "meowpassword" }

> passDataViaObjectOfArrayOfobject.Member[0].name
"meowhecker"

> passDataViaObjectOfArrayOfobject.Member[0].password
"meowpassword"