basicTest.vue 1.4 KB
Newer Older
fxy060608's avatar
fxy060608 已提交
1
<template>
2
    <view class="content">
fxy060608's avatar
fxy060608 已提交
3 4
		<page-head :title="title"></page-head>
        <view v-for="(item,name) in result" :key="name" class="result">
Y
yurj26 已提交
5
            <view>{{name}}测试结果:</view>
fxy060608's avatar
fxy060608 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18
             <view>
                测试api:{{item.passed.join(', ')}}
            </view>
            <view>总共:{{item.total}}</view>
            <view>通过:{{item.passed.length}}</view>
            <view>失败:{{item.failed.length}}</view>
            <view v-for="(fail,index) in item.failed" :key="index" class="failed">
                <view>{{fail.split('\n')[0]}}</view>
                <view>{{fail.split('\n')[1]}}</view>
            </view>
        </view>
    </view>
</template>
19
<script>
fxy060608's avatar
fxy060608 已提交
20 21
    import {
        runTests
22
    } from '../../uni_modules/uts-tests'
fxy060608's avatar
fxy060608 已提交
23 24
    export default {
        data() {
25
            return {
杜庆泉's avatar
杜庆泉 已提交
26 27
				title: 'UTS基础语法',
                result: {}
fxy060608's avatar
fxy060608 已提交
28 29 30 31 32 33
            }
        },
        onReady() {
            this.test()
        },
        methods: {
杜庆泉's avatar
杜庆泉 已提交
34
            test() {
Y
yurj26 已提交
35
                this.result = runTests()
fxy060608's avatar
fxy060608 已提交
36 37 38 39 40
                console.log(this.result)
            }
        }
    }
</script>
41 42
<style>
	@import '@/common/uni-uvue.css';
fxy060608's avatar
fxy060608 已提交
43
	
44
    .content {
fxy060608's avatar
fxy060608 已提交
45 46 47 48 49 50 51 52 53 54
		min-height: 100%;
        padding: 32rpx;
    }

    .passed {
        color: green;
    }

    .failed {
        color: red;
Y
yurj26 已提交
55 56 57
    }
    .result {
        margin-bottom: 20rpx;
fxy060608's avatar
fxy060608 已提交
58
    }
Y
yurj26 已提交
59
</style>